From 13c9dda92664a19189ea3416cb2539bf7d43b8b7 Mon Sep 17 00:00:00 2001 From: Jeremy Collins Date: Wed, 23 Sep 2026 09:08:44 -0400 Subject: [PATCH] Cut the per-thread signal stack to 64 KB std's default signal_stack_size is 256 KiB, and it is a threadlocal, so it is static TLS in libtile57.a. glibc places static TLS inside each thread's stack. With lookout's own copy and the Lua shim's caches, the Lookout Marine Linux app had 614,524 bytes of static TLS, and pthread_create returned EINVAL for its 512 KiB plugin threads. At 64 KiB here and in lookout's core, the app has 221,308 bytes. --- src/lib_root.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib_root.zig b/src/lib_root.zig index 7ac6f64c..01439b91 100644 --- a/src/lib_root.zig +++ b/src/lib_root.zig @@ -6,6 +6,12 @@ //! linked by clang++ in the host (avoiding Zig's linker tripping on the //! system crt's .sframe relocations). +const std = @import("std"); + +/// glibc places static TLS inside each thread's stack, and std's default +/// 256 KB per-thread signal stack is static TLS. +pub const std_options: std.Options = .{ .signal_stack_size = 64 * 1024 }; + // The full engine surface (root.zig + portray) via the named "engine" module, NOT a // root.zig file-import: bundle (below) pulls in engine_full, which owns root.zig, so a // second file-import here would double-claim the file (one-module-per-file per artifact).