From 6504c57176a2a7def07c975af693940fe351bb19 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 27 Oct 2021 15:26:59 -0700 Subject: Compilation: fix crash in the compile error system There is a table of `misc_failures` which previously did not allow multiple errors for the same enum tag. Now it allows this by freeing the previous compile error and replacing it with the new one. Typically this will happen because multiple sub-Compilation objects fail with the same problem, such as not being able to build glibc because of not having LLVM extensions enabled. --- src/Compilation.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Compilation.zig b/src/Compilation.zig index f458fe9f61..8ea6b545b8 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -3849,7 +3849,11 @@ fn setMiscFailure( ) Allocator.Error!void { try comp.misc_failures.ensureUnusedCapacity(comp.gpa, 1); const msg = try std.fmt.allocPrint(comp.gpa, format, args); - comp.misc_failures.putAssumeCapacityNoClobber(tag, .{ .msg = msg }); + const gop = comp.misc_failures.getOrPutAssumeCapacity(tag); + if (gop.found_existing) { + gop.value_ptr.deinit(comp.gpa); + } + gop.value_ptr.* = .{ .msg = msg }; } pub fn dump_argv(argv: []const []const u8) void { -- cgit v1.2.3