
Leaving htop running freezes macOS High Sierra - alpb
https://github.com/hishamhm/htop/issues/682
======
notadoc
High Sierra seems like a great OS if you want an unstable workstation that
doesn't work with tools you've used everyday for well over a decade.

~~~
dm319
I'm not a developer, but I knew developers were previously content with
Macbooks usually running OSX or linux. Given so much unhappiness with OSX, and
the inability to run linux on the USB-C macbook pros, what are developers
generally doing?

The Apple hardware is nice, but it generally means you have to use OSX.
Windows WSL is pretty convenient, but then you have to use Windows. Linux is,
of course, great, but what hardware?

~~~
notadoc
Well this is purely anecdotal, but at least 70% of the developers, IT workers,
and researchers that I know are using prior generation MacBook Pro hardware
(the ones without the touch bar or terrible keyboard, and with ports) and are
intentionally using the older OSX versions.

I know several people who traded in 2016/2017 models for 2015 models because
it's literally an upgrade; get an older machine and you suddenly have usable
ports, a keyboard that works, and an escape key, what a luxury. I also know a
fair amount of people getting Thinkpad and even Surfaces.

~~~
vanilla_nut
An especially unfortunate truth is that many developers have grown so afraid
of workflow-breaking bugs that they're willing to risk security flaws just so
they can get work done.

The things I would do (and pay) for 2010-Apple tier hardware built for CentOS
in both laptop and phone form factors...

~~~
linkmotif
> The things I would do (and pay) for 2010-Apple tier hardware built for
> CentOS

Isn’t it remarkable this still doesn’t exist? Build quality still does not
compare in the PC world.

Yet, I’m on a MBA3,2 (late 2010) and it’s great. Still running Yosemite. It’s
got 4gb ram but handles running 10 JVMs with modest heaps for development no
problem. Stable and runs for months without issue. I’d love more RAM and more
cores but none of these computers seem worth it.

I considered buying a 2015 MPB the other month only to learn that Apple glues
the battery to the top case. So to replace the battery you need to replace the
whole top case. Insane.

~~~
somethingsimple
> Yet, I’m on a MBA3,2 (late 2010) and it’s great. Still running Yosemite.
> It’s got 4gb ram but handles running 10 JVMs with modest heaps for
> development no problem. Stable and runs for months without issue. I’d love
> more RAM and more cores but none of these computers seem worth it.

I have the same hardware but unfortunately my experience is the exact
opposite. It’s barely usable. I literally can’t browse JavaScript-heavy
websites (e.g. Gmail).

I wonder if having kept up with the OS releases has anything to do with it
(I’m on High Sierra).

~~~
tomxor
I'm using an MBP5,1 (2 years older than yours) as my main personal machine
still, it's quite comparable to your MBA3,1, (P8600 vs SL9600), both Core2Duo
roughly same clock speed, same RAM and bus speed etc, but different GPUs, also
I added an x25-M SSD back when that was "new" :P it's lasted well...

I'll admit some of the really heavy websites are crap, but that's mostly
because the websites are crap and wont be smooth on anything than the latest
i7. Generally I have no problem with gmail or google maps which are reasonably
heavy.

Depending on what version of OS X you are using that might be the culprit, OS
X is a pretty heavy OS, especially post 10.6. For me 10.6 was o-k but changing
to linux and a tiling window manager freed up a lot of resources, I never end
up paging out with web browsing even though it's only 4GiB, additionally I
find graphics are faster on linux but that may be GPU and driver specific due
to Apple's underclocking tactics. If I hadn't switched I would probably have
ditched this hardware by now.

Alternatively the GPU difference between these machines may explain web
browsing speed considering how much stuff is hardware accelerated these days.

I think this era of hardware is pretty linux friendly if you wanted to try it,
you don't have dual GPU which is the biggest pain for linux too... there is no
issue with mac EFI from grub anymore so should be zero configuration install
for you, at the most you might have to manually select the proprietary drivers
for your GPU for reasonable performance.

------
saulrh

      1. By creating and closing process very rapidly, one could easily reproduce
      this problem. I used something like `while true; do sh -c "exit 0"; done`.
    

The entire OS dying to rapidly spawned/exited processes permits a pretty nasty
DoS. Good thing that nobody ever uses macs as servers or shared machines.

~~~
btown
Geez; does this mean it could do the same when compiling a large codebase with
Make?

~~~
saulrh
Dunno; I don't have any apple devices. Might ask a coworker to try to repro it
on monday. :P

(I suspect that recursive makes do enough compute in between invocations to
slow down and avoid this bug. If the OS was dying in everyday compile jobs
it'd be much bigger news.)

EDIT: I think that I might've misread this - it might be that spawning
processes pushes htop through codepaths that can cause the bug. So it's more
like "a malicious app could kill your system the instant you open htop". In
which case, yes, a recursive make while you have htop would _would_ do it.
Rather less significant.

------
gnachman
I’ve been disappointed with Apple’s response to kernel bugs for quite a while.
Closing a large number of ptys at once caused a panic for _years_. In high
Sierra, there’s this, statfs hangs, and proc_pidinfo hangs.

------
RJIb8RBYxzAMX9u
Reading the bug report:

1\. Increasing htop's refresh rate (-d 0.1), and having a tight loop that
spawns processes quickly, tends to reproduce fairly reliably. 2\. Running htop
as root seems to work around the problem.

I was able to reproduce the crash with (1), and not able to with (2) after
running htop for several minutes. My first thought was that it didn't have to
with running htop as root, but rather running htop as a different user as the
one spawning processes. So I repeated (1) except that I ran htop as myself,
but the spawning loop as nobody, and the crash went away.

I wonder if the bug's in the resource limit checks (RLIMIT_NOFILE,
RLIMIT_NPROC), and if increasing the limits would delay / mitigate the crash.
But I don't feel like crashing my machine anymore tonight to find out...

~~~
gargravarr
Some nice digging there, thanks for the info!

------
polygot
On Mac OS 10.4 (tiger) when I left Activity Monitor going in the background
for a few minutes and returned to it, sometimes it would all of a sudden
refresh the values super super fast with historical data (appearing to catch
up on the iterations that it did not display.)

On 10.6, when I ran Windows in a virtual machine while it was doing windows
update, and left it running in the background for a few minutes and returned
to it, sometimes I would get 60fps in the machine for a few seconds and it
updated very very fast, and then it went back to 15fps (seemingly getting more
CPU power.)

On 10.7 (if I recall) if I left Activity Monitor running in the background for
a few minutes and returned to it, I would get nonsensical values for the CPU
usage for a few seconds (e.g. 398423.34%) but then it would return to normal.
Perhaps this error has been accumulating over the years.

~~~
to3m
This still happens for me on OS X Sierra sometimes.

~~~
polygot
Out of curiosity, is this bug related to CPU cache? I don't know really
anything about how CPU's work internally, however. It just "feels like" it's
applying a bunch of instructions very quickly but ignoring the internal clock
if that makes any sense.

For example, the CPU percentage counter in Activity Monitor was around
3,000,000. If there was a loop to increment the CPU usage counter, it sounds
like it incremented it so fast that the thread that reset it didn't run since
it wasn't scheduled to run (as it only runs every few seconds.) Again, this is
just pure speculation and if anyone knows otherwise please let me know!

~~~
to3m
I very doubt it's anything to do with the cache, and that isn't an uneducated
guess. But I've very doubted things before, and they turned out to be the case
anyway, so why would you listen to me?

My assumption was/is that it refreshes stuff on a timer. On each timeout it
puts a refresh event on some kind of queue... and then somehow manages to fuck
it up, and ends up having a bunch of these events to deal with all at once,
rather than handling each one as it comes in with a sensible gap between each
one. Well, sometimes it happens, and don't ask me how I know.

But I have to say that you usually don't release it like that :(

------
rubyn00bie
Somewhat tangential but if htop is unusable, I’ve always liked Glances:

[https://nicolargo.github.io/glances/](https://nicolargo.github.io/glances/)

Though it sounds like htop is a symptom not the problem.

~~~
tbrock
Glances seems great but every time I go to use it it’s a pain to install.
Python packaging... yuck!

------
api
People are missing the point-- it's not an htop problem since a simple console
app running as a user should not be able to do this at all.

This gives me the willies. Methinks another OSX security bug is incoming.

~~~
djsumdog
Yea, if I had a Mac box, I'd be looking at that call stack the author posted
and fuzzing the hell out of those functions. There's a DoS bug bounty in there
somewhere.

~~~
Someone
Only if Apple invited you to that competition
([https://www.macworld.com/article/3104671/security/apple-
anno...](https://www.macworld.com/article/3104671/security/apple-announces-
invitation-only-bug-bounty-program-at-black-hat-conference.html)). Others only
get credits.

------
Sir_Cmpwn
Why was this reported to htop instead of Apple? Most of these people "me
too"ing don't seem to realize that this isn't htop's problem...

~~~
djsumdog
Yea, there's very little indication anyone here has tried to do any serious
debugging or realizing this should be a security vulnerability report. The
author did eventually post a stack-trace to the actual call that's failing.

------
calinet6
This seems like it might be a lead:

> Apple completely rewrote the window server in Metal 2 for High Sierra and
> seems to have done a very poor job of it.

I've run into tons of those issues with my 2012 MBP. Slight tangent that might
be useful to someone.

If you experience jerkiness, lagginess, slow display updates, just general
slow feeling, one thing to try is the NVIDIA Web Driver video drivers, rather
than the stock ones.

It resolved all of the slowness for me, maybe just applies to slightly older
macs but made a big difference.

------
gjvc
Since Mac OS X Snow Leopard (10.6) the quality has declined release by
release.

~~~
grzm
> _" Since Mac OS X Snow Leopard (10.6) the quality has declined release by
> release."_

This may be: I'd love to see a comprehensive, in-depth article that digs into
this in a quantitative manner. Do you have one at hand? If so, it might make a
good HN submission. Just posting this statement at the top level of a post is
arguably off-topic and baity. If you could post it on any submission that
touches on Mac OS X, it's not really on-topic.

------
oceanghost
I've had a similair problem with Transmission for years. Doing more then a few
transfers locks up transmission and then the entire machine. Issuing a halt at
the terminal sometimes will reboot the machine, but moist of the time it just
hangs.

I would switch but to what? Windows/Linux are just as user hostile.

~~~
voltagex_
I'd say OS X is hostile now - after doing maintenance on a 2015 Macbook over
the holidays.

~~~
oceanghost
I'd agree. It's just relative.

------
rdtsc
Yup. I hit the same bug, just a few hours ago. Was compiling something and had
htop running, then everything froze. I assumed it was the build and after a
hard reboot started compiling again but this time without the htop and it
finished fine.

------
nikanj
I’m still looking for a thing I _can_ leave running, without High Sierra
freezing on me..

~~~
robotresearcher
Linux?

:)

------
saagarjha
From the symptoms, it looks like it’s starving the computer of memory. It
doesn’t look like anyone’s debugged this, so once I get back to my computer
I’ll take a look and get it reported to Apple.

~~~
saagarjha
I can't edit anymore, so I'm going to reply: I did a bit more research on this
issue and it's not actually a memory bug at all. In reality there appears to
be an infinite loop in calls to task_for_pid:
[https://github.com/hishamhm/htop/issues/682#issuecomment-355...](https://github.com/hishamhm/htop/issues/682#issuecomment-355736956).
I'm still not sure who's doing the wrong thing, htop or Apple, but it's clear
that freezing up the system is _always_ incorrect behavior.

~~~
yjftsjthsd-h
Kinda sounds like an htop bug that shouldn't be able to freeze the system
because, y'know, not letting any process freeze the system is part of the OS's
job. Of course, it might also be an htop bug that's triggered by Darwin
handing it bad data, so there could be blame to share;)

------
duncan_bayne
I have an old MacBook Pro I use as a gaming machine (and my wife uses as
temporary machine after our late dog (for reasons unrelated to her demise)
urinated on her new XPS13.

After upgrading to High Sierra, we both got so sick of the instability that
we're installing it with Xubuntu this evening, bringing it in line with the
rest of our 'home fleet' (ThinkPads w/ either FreeBSD or Xubuntu).

------
hit8run
Oh crazy I was wondering if my system was totally messed up for quite a few
weeks now. Thought it had to do with my homebrewed version of htop but didn’t
have time to investigate further :/

------
alwillis
Ran htop for a while on the latest public beta of High Sierra 10.13.3 last
night and didn’t have any issues.

~~~
ufo
According to the bug thread, the bug doesn't always happen but there are some
things that can be done to reliably trigger it.

[https://github.com/hishamhm/htop/issues/682#issuecomment-341...](https://github.com/hishamhm/htop/issues/682#issuecomment-341538158)

------
jamix
Wow. I used to update my iOS and macOS every year, but decided not to do so in
2017. A stroke of luck?

------
fooker
My 2015 13 inch MBP is still on Sierra. Should I indefinitely hold off
upgrading to High Sierra?

~~~
justinph
Yes. Stay away.

I downgraded my mac back to Sierra from High Sierra and don't regret it at
all.

~~~
chmaynard
+1. I used to upgrade to each new release of Mac OS X in the first few days.
That policy worked for many years, but my experience with High Sierra was so
bad that I downgraded and never looked back.

------
evanslify
I’ve been finding the root cause of this a month ago, but don’t know where to
look due to lacking of experience in kernel debugging. If anyone here could
lend me a hand, please send me an email at (es at evsfy dot com)

~~~
therealmarv
why keeping the root cause for yourself? Try to mention it at least here or
write on the htop bug list page what you know. It would help us all I guess.

~~~
evanslify
I did post my findings on the GitHub issue :-)

------
hit8run
Okay for now htop is disabled for High Sierra:

==> Upgrading 1 outdated packages, with result: htop 2.0.2_1 htop: This
formula either does not compile or function as expected on macOS

~~~
saagarjha
Not quite: many people already have 2.0.2 (which is buggy) installed. Short of
uninstalling htop the issue still remains.

------
alasdair_
High Sierra STILL has a bunch of issues running Unity too.

------
j_m_b
macOS has gone down hill since it heyday in the 2000s, very noticeably so
since it became known as 'macOS'. For a long time, it was the best _nix you
could run. The horror stories surrounding High Sierra might finally break my
bad habit of commercial OS and make me go back to Linux or one the_ BSDs.

------
Dunedan
Leaving htop running (best in background in a screen session on some server)
is such a waste of CPU resources. I've already seen that multiple times and
always wondered if the people don't recognize by looking at htop's output how
much CPU resources it wastes.

------
alvil
Htop is pretty leaky on any system.

~~~
felipelemos
Yes, with a small difference that this does not happen on a Linux box.

------
tedmiston
I always wondered why people bother with htop on OS X when the built-in
Activity Monitor.app is so nice already.

I only use htop on remote boxes myself.

~~~
ufo
I have always wondered why people bother with non-htop apps, when htop is so
nice already :)

But more seriously, one of the big advantages of htop is that it is extremely
lightweight, which helps a lot when you have other processes that are eating
up all your CPU and RAM.

~~~
tedmiston
I think htop is a tolerable replacement for top but personally I find it just
okay, not "nice".

The main reason I prefer Activity Monitor is that it has more features, like
viewing open files by process, the energy usage pane and network activity on
top of CPU and memory. I tend to prefer GUI apps any time I'm interacting with
the interface a lot, like to sort, filter, drill down, etc.

~~~
hisham_hm
htop allows viewing open files by process (press 'l'), as well as sorting (F6
or click column header) and filtering (F4 or '/').

