Fix regression on inappropriately truncated command name#1889
Fix regression on inappropriately truncated command name#1889BenBE merged 1 commit intohtop-dev:mainfrom
Conversation
|
Gentle ping. Issue #1817 is still current. Is there anything I can do to help this pull request progress? Maybe rebase on main and re-test? |
|
Sorry, had little time recently and reviewing this one takes a bit of time as there are several edge cases we need to take care of. Rebasing onto main should be trivial enough with this one so not strictly necessary.. That's more important with more complicated patch sets that affect a broader part of the code. With this PR it's mostly looking at things like ssh, processes that have square brackets in their cmdline, … Or things like postgres ( |
|
@BenBE: Thanks for your feedback! I took a look on my Debian trixie server, comparing the output of htop from main (3066c68 "Merge pull request #1918 from ViryBe/main") and from this pull request. I enabled the display of kernel threads, as you suggested. Below are the only differences I could find:
The fist two processes (PHP and SSH) are as I expected: they were my original motivation for this. The two kernel threads that follow are a surprise to me: I do not understand why they are displayed differently. FWIW, this pull-request's version seems to get the names right: $ sudo file /proc/551377/exe
/proc/551377/exe: unreadable symlink `/proc/551377/exe' (No such file or directory)
$ sudo cat /proc/551377/cmdline | hd
$ sudo cat /proc/551377/comm | hd
00000000 6b 77 6f 72 6b 65 72 2f 75 38 3a 33 2d 65 76 65 |kworker/u8:3-eve|
00000010 6e 74 73 5f 75 6e 62 6f 75 6e 64 0a |nts_unbound.|
0000001cThe other kernel thread (554353) shows exactly the same:
I have two of them, and both of them seem to get correctly displayed, with or without this PR:
I do not have Postgres here.
I have a couple of these. Again, they both seem fine, with or without this PR:
|
Some programs, such as php-fpm and sshd-session, rewrite their command line and pad it with NUL characters. When this happens, LinuxProcessTable_readCmdlineFile() believes that NUL is used as an argument separator, and fails to invoke the argument parsing heuristic designed to handle this situation. Only assume NUL is an argument separator if a non-NUL character is found after the first NUL. Fixes: 1f664ee ("Properly track if we actually hit any token while scanning cmdline") Closes: #1817
As mentioned in #1817, in
LinuxProcessTable_readCmdlineFile(),argSepNULis being set if any character is found after the first NUL, which is incorrect.This pull request changes the behavior to only set the flag when a non-NUL character is found after the first NUL.
Tested on Debian trixie. Both problematic processes mentioned in the issue are now displayed correctly.
Fixes: #1817