-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior
Description
Zig Version
0.16.0-dev.577+c50aa2b95
Steps to Reproduce and Observed Behavior
- Put this into
test_program.zig
:
const std = @import("std");
pub fn main() void {
var buffer: [19 * (1 << 20)]u8 = undefined;
std.mem.doNotOptimizeAway(&buffer);
std.debug.print("Last: {}\n", .{buffer[buffer.len - 1]});
}
- Now put this into
check_segfault.sh
:
#!/bin/bash
zig build-exe test_program.zig
./test_program &> /dev/null
if [ $? -eq 139 ]; then
exit 0
else
exit 2
fi
- Mark the script as executable:
chmod +x check_segfault.sh
- Set your process stack limit to 8 MiB:
ulimit -s 8192
- Run
./check_segfault.sh
, process returns2
(interesting forzig reduce
) - Now run
zig reduce ./check_segfault.sh test_program.zig
, you observe the following:
smoke testing the interestingness check...
error: interestingness check returned boring for unmodified input
You can also run this, which segfaults:
zig build-exe test_program.zig
./test_program
Whereas this DOES NOT segfault:
zig run test_program.zig
Expected Behavior
Zig should run it's child processes with the same stack limits as Zig's parent process. This hid the very issue I was trying to zig reduce
earlier today. A workaround is to put ulimit -s [stack size]
into the interestingness script itself, but I don't consider that a solution.
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior