summaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main.zig b/src/main.zig
index 64614daa..ea2db917 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -16,7 +16,11 @@ pub const std_options_debug_io: std.Io = if (is_emscripten)
else
std_options_debug_threaded_io.?.io();
-pub const std_options: std.Options = .{ .logFn = logFn };
+// Every thread's alternate signal stack is a threadlocal that libc zeroes as
+// the thread starts, so std's 256 KiB made each 9P connection's thread cost
+// that much resident. A stack-overflow segfault on a thread still printed its
+// whole symbolized trace from 32 KiB up (16 KiB double-faulted): 64 KiB.
+pub const std_options: std.Options = .{ .logFn = logFn, .signal_stack_size = 64 * 1024 };
fn logFn(
comptime level: std.log.Level,
@@ -328,7 +332,11 @@ fn webMain() !void {
// malloc otherwise. Kept on purpose: glibc's malloc was measured at least as
// fast as std.heap.smp_allocator on every scenario and faster on MuPDF's
// page-sized rasters. macos.zig makes the same choice for itself.
-fn nativeMain(init: std.process.Init) !void {
+fn nativeMain(std_init: std.process.Init) !void {
+ var init = std_init;
+ // Zig 0.17's std.start gives a safe build a SafeAllocator over the page
+ // allocator, not libc's malloc: hand the shells malloc, as above.
+ if (builtin.mode != .debug) init.gpa = std.heap.c_allocator;
var stderr_probe: [64]u8 = undefined;
_ = std.debug.lockStderr(&stderr_probe);
std.debug.unlockStderr();