From ecce844d227dcb9136a91355ea9e6ec543165fde Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 30 Oct 2026 15:19:25 -0300 Subject: c_heap: a heap's allocator read as its bytes are, through a volatile pointer: std's stateless allocators (c_, page_, smp_, wasm_allocator) leave `ptr` undefined, and one never written outside a test (replica.zig's zstd heap over c_allocator, web.zig's over wasm_allocator) is a constant to a release build, which folded `known.ptr == current.ptr` to false: every malloc named a new allocator and the 65th panicked (the box's session aborted at about its 16th far join; the core's table held 64 copies of {ptr 0, c_allocator's vtable}); its test runs built ReleaseSafe in unit-test too, where it panicked before Co-Authored-By: Claude Opus 5.5 --- build.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'build.zig') diff --git a/build.zig b/build.zig index 5e88ef68..4485140d 100644 --- a/build.zig +++ b/build.zig @@ -1928,18 +1928,20 @@ pub fn build(b: *std.Build) void { const history_step = b.step("history-test", "test historical comparisons and regression gates"); const protocol_match = testMatch(b, unit_profile, test_filters, protocol_step); const history_match = testMatch(b, unit_profile, test_filters, history_step); - for ([_]struct { path: []const u8, libc: bool }{ + for ([_]struct { path: []const u8, libc: bool, optimize: ?std.builtin.OptimizeMode = null }{ .{ .path = "test/history.zig", .libc = false }, .{ .path = "src/9p.zig", .libc = false }, .{ .path = "src/esp32p4_gpio.zig", .libc = false }, .{ .path = "src/esp32p4/input_rescue.zig", .libc = false }, .{ .path = "src/fonts.zig", .libc = true }, .{ .path = "src/c_heap.zig", .libc = false }, + // Its lookup goes wrong only where the optimizer folds it. + .{ .path = "src/c_heap.zig", .libc = false, .optimize = .ReleaseSafe }, }) |entry| { const tests = b.addTest(.{ .root_module = b.createModule(.{ .target = target, - .optimize = optimize, + .optimize = entry.optimize orelse optimize, .root_source_file = b.path(entry.path), .link_libc = entry.libc, }), -- cgit v1.3