diff options
| author | Ben Sima <ben@bsima.me> | 2025-11-15 13:39:15 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bsima.me> | 2025-11-15 13:39:15 -0500 |
| commit | 48afd6bdb135177842af593c7f96846b9ddab7d8 (patch) | |
| tree | b1be373909d90e17c9ab158f365ff8bf11f5b9ca /Omni/Users.nix | |
| parent | d2253e15dd405b3fbf15663aa02ab1f5ffa56306 (diff) | |
Expand terminalLock scope to protect all terminal I/O
Problem: Still getting segfaults ("free(): invalid pointer") even
with ncurses calls protected. The mutex only covered ANSI calls, but
IORef reads and IO.hPutStr operations were happening outside the lock.
Root cause: Race conditions in concurrent terminal output: 1. Multiple
threads reading namespaceLines IORef concurrently 2. Interleaved
IO.hPutStr calls corrupting output buffer 3. Rainbow.hPutChunks not
being thread-safe
Solution: Expand terminalLock scope to cover entire output operations:
- Move IORef reads inside the lock - Protect all IO.hPutStr and
Rainbow.hPutChunks calls - Lock both SingleLine and MultiLine modes -
Ensure atomicity from IORef read through all I/O to flush
This makes each updateLine/updateLineState call atomic, preventing
any interleaving of terminal operations between threads.
Changes: - updateLine SingleLine: wrap entire output in withMVar
terminalLock - updateLine MultiLine: move nsMap read inside lock -
updateLineState SingleLine: wrap entire output in withMVar terminalLock
- updateLineState MultiLine: move nsMap read inside lock
Tested: 10/10 successful runs of `bild --time 0 **/*` without
segfaults.
Diffstat (limited to 'Omni/Users.nix')
0 files changed, 0 insertions, 0 deletions
