Open
Description
Zig Version
0.14.0-dev.3385+055969b10
Steps to Reproduce and Observed Behavior
test "pointer to sentinel array free" {
const allocator = @import("std").testing.allocator;
const a = try allocator.allocSentinel(u8, 2, 0);
defer allocator.free(a[0..2 :0]); // error with invalid free, due to sentinel not being accounted (type is *[2:0]u8)
}
Crashes with:
thread 20107 panic: Invalid free
/home/blockog/zig/lib/std/heap/debug_allocator.zig:870:49: 0x1055dbb in free (test)
if (bucket.canary != config.canary) @panic("Invalid free");
^
/home/blockog/zig/lib/std/mem/Allocator.zig:147:25: 0x10568a3 in free__anon_1623 (test)
return a.vtable.free(a.ptr, memory, alignment, ret_addr);
^
/home/blockog/crash.zig:5:25: 0x1054e6b in test.pointer to sentinel array free (test)
defer allocator.free(a[0..2 :0]); // error with invalid free, due to sentinel not being accounted (type is *[2:0]u8)
^
/home/blockog/zig/lib/compiler/test_runner.zig:214:25: 0x10dcf13 in mainTerminal (test)
if (test_fn.func()) |_| {
^
/home/blockog/zig/lib/compiler/test_runner.zig:62:28: 0x10d7b2b in main (test)
return mainTerminal();
^
/home/blockog/zig/lib/std/start.zig:647:22: 0x10d718b in posixCallMainAndExit (test)
root.main();
^
???:?:?: 0x0 in ??? (???)
Expected Behavior
It should be able to free it just fine