Terminal freezes with beach ball on High Sierra

high sierraterminal

My terminal frequently freeze with a spinning beach ball of doom. I've tested using both iTerm2 and the default Terminal, and it happens with both. And it doesn't seem to matter what I'm doing. I've had it freeze while nothing is running in any terminal, as well as while running a myriad of different programs (npm, webpack, gulp etc.).

When the terminals freeze, I'm able to force quit the app, but unable to start it again. And if one freeze, it seems to affect the other (if iTerm2 freeze and I force quit the app, I'm still unable to open Terminal). In order to use a terminal again I'm forced to reboot the machine.

While rebooting (after a terminal freeze) the machine also always hangs after closing all apps. I'm still able to move the cursor around on a black background, but that's it. The machine hangs there until I short circuit by holding down the power button.

What I've tried

I've tried resetting NVRAM and SMC to no avail.

Best Answer

You are likely being hit by a macOS 10.13.2 kernel bug, described here, and exposed pretty regularly by htop, described here.

Supposedly, macOS 10.13.4 beta has a kernel fix, and version 2.10.0 of htop was released to work around this bug.