Open andrewrk opened 2 weeks ago
I'm not sure this is the same bug, but may be related:
const std = @import("std");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{
.safety = true,
.thread_safe = true,
.never_unmap = true,
.retain_metadata = true,
}){};
const allocator = gpa.allocator();
const ptr = try allocator.alloc(i32, 10);
// Free the memory once
allocator.free(ptr);
allocator.free(ptr);
}
$ zig-master run -O ReleaseSafe ./test_buf_overflow.zig
error(gpa): Double free detected. Allocation:
First free:
Second free:
$
^ No error location information.
Zig 0.14.0-dev.2034+56996a280
no stack trace here either: Zig Version 0.14.0-dev.2162+3054486d1
Steps to Reproduce and Observed Behavior
const Structure = enum(u8) {
HasAmount = 0x10,
HasData = 0x20,
HasCommitmentLength = 0x40,
Reserved = 0x80,
};
const Capability = enum(u8) {
None = 0x0,
Mutable = 0x01,
Minting = 0x02,
};
fn hasData(bitfield: u8) bool {
return bitfield & @intFromEnum(Structure.HasData) != 0;
}
fn hasAmount(bitfield: u8) bool {
return bitfield & @intFromEnum(Structure.HasAmount) != 0;
}
fn hasCommitmentLen(bitfield: u8) bool {
return bitfield & @intFromEnum(Structure.HasCommitmentLength) != 0;
}
fn isMutable(bitfield: u8) bool {
return hasData(bitfield) and @intFromEnum(Capability.Mutable) != 0;
}
fn isMinting(bitfield: u8) bool {
return isMinting(bitfield) and @intFromEnum(Capability.Minting) != 0;
}
fn getcapability(bitfield: u8) u8 {
return bitfield & 0x0f;
}
test "test" {
const bitfield: u8 = 113;
const is_mut = isMutable(bitfield) and isMinting(bitfield);
_ = is_mut;
}
error: the following test command crashed: /Users/johndoe/.cache/zig/o/1744a080f14dd669409f1bc036c4a248/test --seed=0x5e44a8a7
Zig Version
0.14.0-dev.2034+56996a280
Steps to Reproduce and Observed Behavior
Expected Behavior
Expected to see a stack trace, like what happens if you run that example on Linux.