Std.testing.allocator causes my tests to hang

Hi!

I don’t know if I’m missing something or if I found a regression in zig 0.17. I have a project where everything worked on zig 0.16, but after upgrading the project to 0.17, my tests hangs, never finishing or even crashing. I found that making a DebugAllocator that I instantiate myself solves the problem before realizing that it’s not the same type.

I thought it may be an issue in my code but it happens in std.json.parseFromSlice and other seemingly random places where I use the allocator. I don’t know how to begin debugging that further…

I don’t know if it help but here is the first spot where is hangs, it’s also the first usage of the allocator:

test "interpolation.json" {
    try run_tests_file("tests/specs/interpolation.json", false);
}

fn run_tests_file(comptime filename: []const u8, verbose: bool) !void {
    // The commented lines prevent the issue
    //var debug: std.heap.DebugAllocator(.{}) = .init;
    //const allocator = debug.allocator();
    const parsed = try std.json.parseFromSlice(
        test_tools.Spec,
        testing.allocator,
        //allocator,
        @embedFile(filename),
        .{
            .allocate = .alloc_always,
            .ignore_unknown_fields = true,
        });
    defer parsed.deinit();
    const spec = parsed.value;
    // etc...

Right as I post this, 0.17.1 is released. I though this fix could have covered my issue https://codeberg.org/ziglang/zig/issues/37310 but I have the same problem. If anything it just confirm I should open an issue…

A full, compilable reproduction is always helpful for situations like this.

I spent a lot of time trying to reproduce the issue but couldn’t. I went back to my original project and it turns out I only needed to clear ./zig-cache…

So yeah… zig 0.17.1 fixed the issue and I feel a bit dumb…