#52 pstree show wrong info

Next Release
closed
nobody
None
5
2014-01-31
2012-06-24
Alex
No

22.16 is normal

{{{
init-+-acpid
|-agetty
|-klogd
|-ntpd
|-screen-+-bash---openwrt.sh---make---sh---make---bash---make---make---make---sh
| |-bash
| -bash---pstree |-sshd-+-sshd---sshd---sftp-server |-sshd---sshd---bash---screen
|-syslogd
`-udevd---udevd
}}}

but sine 22.17

init-+-2*[screen-+-bash---openwrt.sh---make---sh---make---bash---make---make---make---sh]
| |-bash]
| -bash---pstree] |-bash---pstree |-bash---openwrt.sh---make---sh---make---bash---make---make---make---sh |-acpid |-agetty |-klogd |-ntpd |-sshd-+-sshd---sshd---sftp-server |-sshd---sshd---bash---screen
|-syslogd
`-udevd---udevd

Discussion

  • TroY
    TroY
    2012-07-25

    Hi,

    "git bisect" says this bug was introduced by commit 26f9b6c: "Fake pstree root with kernels with hidepid".

    It's a little tricky to reproduce: A process's PID must be less than it's PPID. The actual bug is not clearly visible in xinglp's comment. You'll get something like this:

    init(1)─┬─...
    ├─bash(23159)─┬─less(7195)
    │ ├─pstree(7193)
    │ └─sed(7194)
    ...
    ├─xterm(23158)───bash(23159)─┬─less(7195)
    │ ├─pstree(7193)
    │ └─sed(7194)
    ...

    I guess SourceForge will mess up that listing, so better have a look at it here:

    http://www.uninformativ.de/patches/2012-07-25-pstree/tree

    Note the PIDs. As you can see, bash(23159) is listed twice. The lower one with parent 23158 is the correct one. Also note that less(7159) is a child of bash(23159) and 7159 < 23159.

    pstree iterates over all processes ordered by their PID. Thus, PID 7195 will be processed before PID 23159. Let's assume we're in add_proc() for PID 7195. Now, add_proc() calls find_proc(23159) which fails, of course. The bug is that the aforementioned patch now thinks hidepid is in effect and calls add_child(root, 23159) -- although 23159's parent is 23158.

    I'm not sure how to fix this properly. IMHO, pstree should explicitly check whether hidepid is activated.

    Thank you!

     
  • Craig Small
    Craig Small
    2012-08-31

    commit f118a020b35fe6ad3d844478363dcf3186556204 fixes this problem, the explanation is below, thanks tony for your analysis which got me onto the right path.

    Commit 26f9b6c1553d021c0bf9dd85f0647dc6e210948d while fixing the missing
    root pid problem introduced another problem where PIDs are out of order.
    A process that has a lower PID than its PPID would appear twice with
    the tree breaking in strange ways.

    We now scan the entire process tree first then perform two checks
    if PID==1 is missing add it
    if a process has no parent, then make it a child of PID==1, either the
    real one or the faked one made in step 1

    As this is done after all procsses are found, we don't get the previous
    breakage.

     
  • TroY
    TroY
    2012-08-31

    Alright, thank you. Fix confirmed. :)

     

  • Anonymous
    2012-12-03

    whoch version fixes this problem?
    I'm running 22.19-1 and the problem is still present.

     
  • Craig Small
    Craig Small
    2012-12-09

    It's in the git repository not in a released version, which is why the bugs status is pending and not closed. Once there is a released tar.gz then this bug gets closed.

    If you know how to use git to get an interim version you can test it, which is what I assume Troy did to say its all good for him.

     
  • Craig Small
    Craig Small
    2014-01-31

    • status: pending --> closed
    • Group: --> Next Release
     


Anonymous


Cancel   Add attachments