summaryrefslogtreecommitdiff
path: root/Biz.nix
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2025-11-15 12:52:26 -0500
committerBen Sima <ben@bsima.me>2025-11-15 12:52:26 -0500
commit7384d1297dbf6929063e6d3f15f7903a4d20e5ef (patch)
tree25fadc022571eb8938deca4ce5366b27c9bdb55f /Biz.nix
parentb3dd5f285365f59153a8f4549efa0607ccddf19d (diff)
Fix segfault: add mutex for ANSI terminal operations
Problem: Intermittent segfaults when running `bild --time 0 **/*` with many concurrent builds. Core dumps showed crashes in libncursesw's free() function during terminal cleanup. Root cause: ANSI.getTerminalSize and other ANSI terminal library calls are not thread-safe. With mapConcurrentlyBounded running up to 8 analyses concurrently, multiple threads were calling ANSI functions simultaneously, causing memory corruption in the ncurses library. Solution: Add global MVar terminalLock to serialize all ANSI terminal operations. Wrap all ANSI function calls (cursor movement, line clearing, etc.) with withMVar terminalLock. Changes: - Add terminalLock :: MVar () in Omni/Log/Concurrent.hs - Wrap all ANSI calls in withMVar terminalLock: - initializeLines: cursor column, clear line - updateLine: cursor up/down, column set, clear line - updateLineState: cursor up/down, column set, clear line - withLineManager: cursor up Tested: 5 consecutive runs of `bild --time 0 **/*` complete without segfaults (previously failed 1-2 out of 3 runs).
Diffstat (limited to 'Biz.nix')
-rwxr-xr-xBiz.nix48
1 files changed, 24 insertions, 24 deletions
diff --git a/Biz.nix b/Biz.nix
index 3ccf955..c9e91c3 100755
--- a/Biz.nix
+++ b/Biz.nix
@@ -17,28 +17,28 @@
# wire them together as necessary here, but I don't know how that works so I'll
# just stick to this method for now.
bild.os {
- imports = [
- ./Omni/Cloud/Hardware.nix
- ./Omni/Os/Base.nix
- ./Omni/Packages.nix
- ./Omni/Users.nix
- ./Biz/Storybook.nix
- ./Biz/PodcastItLater/Web.nix
- ./Biz/PodcastItLater/Worker.nix
- ];
- networking.hostName = "biz";
- networking.domain = "storybook.bensima.com";
- time.timeZone = "America/New_York";
- services.storybook = {
- enable = false;
- package = packages.storybook;
- };
- services.podcastitlater-web = {
- enable = true;
- package = packages.podcastitlater-web;
- };
- services.podcastitlater-worker = {
- enable = true;
- package = packages.podcastitlater-worker;
- };
+ imports = [
+ ./Omni/Cloud/Hardware.nix
+ ./Omni/Os/Base.nix
+ ./Omni/Packages.nix
+ ./Omni/Users.nix
+ ./Biz/Storybook.nix
+ ./Biz/PodcastItLater/Web.nix
+ ./Biz/PodcastItLater/Worker.nix
+ ];
+ networking.hostName = "biz";
+ networking.domain = "storybook.bensima.com";
+ time.timeZone = "America/New_York";
+ services.storybook = {
+ enable = false;
+ package = packages.storybook;
+ };
+ services.podcastitlater-web = {
+ enable = true;
+ package = packages.podcastitlater-web;
+ };
+ services.podcastitlater-worker = {
+ enable = true;
+ package = packages.podcastitlater-worker;
+ };
}