Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

htop F5 (process tree) hangs if processes do not form a tree #1125

Open
roy-work opened this issue Nov 4, 2022 · 1 comment
Open

htop F5 (process tree) hangs if processes do not form a tree #1125

roy-work opened this issue Nov 4, 2022 · 1 comment
Labels
enhancement Extension or improvement to existing feature MacOS 🍏 MacOS / Darwin related issues

Comments

@roy-work
Copy link

roy-work commented Nov 4, 2022

I was attempting to debug some stability problems w/ my system (macOS, Monterey, 12.4).

Pressing F5 hangs htop currently on this laptop.

It is almost certainly because of this, and honestly I'm hesitant to call this a bug in htop at all, given that the following is Grade A Insane:

» ps -ef | grep '26699\|20838\|20956\|20838'
  501 20838 26699   0  3:15PM ??         0:00.00 (lldb)
  501 20956 20838   0  3:15PM ??         0:00.00 (debugserver)
  501 26699 20956   0 21Sep22 ??         0:00.00 (gimp)
  501 26808 26699   0 21Sep22 ??         0:00.00 (script-fu)
  501 31031 26930   0  3:25PM ttys103    0:00.00 grep --color 26699\|20838\|20956\|20838

Here, the parent-child relationships between processes have formed a cycle: (gimp) → (is a child of) → (debugserver) → (is a child of) → (lldb) → (is a child of) → gimp (!) → …

So, my guess is that htop probably expects (very reasonably) the data from the OS to form a tree.

The only reason I file this at all is just that, naturally, I opened htop because I was having difficulties killing GIMP, and wanted to investigate. Since htop is used in debugging contexts, IDK if it wants to handle this little bit of insanity better that hanging. Something like an immediate abort of htop with the diagnostic of something like,

htop: aborted: the processes on your system do not form a tree: <PIDs that form a cycle>

Would be completely reasonable, and at least instantly give the user a direction that, hey, it's not htop's fault.

Unless, like, macOS doesn't enforce that PIDs form a tree, completely contrary to my expectations of how a *nix works.

(Don't ask me how I managed to form a process cycle. I have no idea! I was running GIMP, and a piece of it's UI had become disconnected from it and was just hanging out on my screen, of course floating on top of all other UI, and being in the way. I tried to force kill it, that didn't work, I `kill -9`'d it — _that_ didn't work — I noticed `lldb` running and figured that it was probably just trying to core GIMP or something, didn't want that, tried to kill `lldb` and now we're here.)

Imma reboot now.

@fasterit fasterit added enhancement Extension or improvement to existing feature MacOS 🍏 MacOS / Darwin related issues labels Nov 4, 2022
@BenBE
Copy link
Member

BenBE commented Nov 4, 2022

Some OS re-parent a process when attaching a debugger to an process. Thus it's quite normal behaviour to see this kind of loops (IIRC Linux is one of the OSes that doesn't re-parent things, thus there you won't see this issue).

Nonetheless, htop should handle this more gracefully and for example not hang … ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Extension or improvement to existing feature MacOS 🍏 MacOS / Darwin related issues
Projects
None yet
Development

No branches or pull requests

3 participants