#1862·btop

[BUG] btop locks up (1.4.7) or exits (main) after the terminal stops reading output for a while, e.g. macOS pausing apps under memory pressure

Author: IceeWokCreated Sep 26, 2026Updated Sep 30, 2026

Describe the bug

When the terminal btop is running in stops reading output for more than a few seconds, btop 1.4.7 locks up permanently: no redraws and no response to input, and the terminal has to be killed. On current main the same trigger makes btop exit with ERROR: Runner thread stalled for 30s, exiting. instead.

I hit this regularly on macOS under heavy memory pressure: macOS shows the "Your system has run out of application memory" dialog and pauses apps, including the terminal. When the terminal is resumed, btop is frozen. ~/.local/state/btop.log has one ERROR: Stall in Runner thread, restarting! line per occurrence (14 since mid-August).

To Reproduce

No memory pressure needed. Run btop in a pty and stop draining the pty master for ~45 seconds (this is what a paused terminal looks like to btop), then resume draining and send q.

Measured with a small Python pty harness, -u 1000:

Build Output before pause Output after resume q
1.4.7 (Homebrew) 48,930 B/s 0 B/s no response, must SIGKILL
main @ 7b1f128 normal exits after 30s n/a

Expected behavior

btop resumes drawing once the terminal reads again.

Cause

The runner thread blocks in its final cout << ... << flush while the terminal is not reading. Runner::run() treats that as a stalled runner.

  • In 1.4.7 it logs Stall in Runner thread, restarting!, calls pthread_cancel, then pthread_join. Once the terminal resumes, the write completes and the runner goes back to waiting on its semaphore (__libcpp_atomic_wait / __ulock_wait), which is not a cancellation point, so pthread_join never returns. sample of the hung process:
Thread main:
  btop_main -> Runner::run(...) -> _pthread_join -> __ulock_wait
Thread runner:
  _runner -> std::__libcpp_atomic_wait -> __ulock_wait
  • On main, 3c6cfda removed pthread_cancel, so the hang became a clean_quit(1) after the 30s watchdog in Runner::run(), which still counts time blocked on terminal output.

Info

  • btop++ version: 1.4.7 (Homebrew), also current main @ 7b1f128
  • Binary: Homebrew and self compiled
  • Architecture: arm64
  • Platform: OsX
  • Os release version: macOS 26.6.2