#Debug allocator crashes

1 messages · Page 1 of 1 (latest)

empty violet
#

The debug allocator crashes for me in the new update 0.15.1, am I doing something wrong?

const std = @import("std");

pub fn main() !void {
    var gpa = std.heap.DebugAllocator(.{}).init;
    std.debug.assert(gpa.deinit() == .ok);
    const allocator = gpa.allocator();

    const buffer = try allocator.alloc(u8, 10000);
    allocator.free(buffer);
}

When run the program crashes on the allocator.alloc with the error:

General protection exception (no address available)
/home/drust/.local/share/zigup/0.15.1/files/lib/std/heap/debug_allocator.zig:755:42: 0x1140d46 in alloc (std.zig)
                const slot_index = bucket.allocated_count;
                                         ^
/home/drust/.local/share/zigup/0.15.1/files/lib/std/mem/Allocator.zig:129:26: 0x10bf38e in allocBytesWithAlignment__anon_14378 (std.zig)
    return a.vtable.alloc(a.ptr, len, alignment, ret_addr);
                         ^
(...)
little forge
#

u've deinitialized gpa by the time you allocate

empty violet
#

oh i forgot defer

#

lmao