Segfault on array_hash_map.Custom.get()

Hey,
pretty much new to Zig. Excited to be here and grateful for all the hard work done on this amazing language!

I am trying to familiarize myself with the std.json API, since I intend on creating a json schema validator in zig.

By doing so I triggered a segfault with the following example code:

    const res = try std.json.parseFromSlice(std.json.Value, gpa, "{ \"type\": \"number\", \"value\": 69 }", .{});
    res.deinit();
    switch (res.value) {
        .object => |map| {
            const ty = map.get("type");
            std.debug.print("{any}\n", .{ty});
        },
        else => {},
    }

My debugging capabilities are very limited and I am probably doing something wrong here. So before doing a bug report I wanted to understand the issue better or even ask for any hints.

Thanks in advance!

PS.
I am running zig 16.0 aarch64 in debug mode on a mac.

You forgot defer for the res.deinit.

For future memory related problems adding the stack trace would be of great help to us.

3 Likes

Ah, stupid me, I figured that I must have messed something up.
Will paste the stack trace the next time I need help. Thank you very much, much appreciated!