authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-10-27 15:26:59-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-10-27 15:26:59-07:00
log6504c57176a2a7def07c975af693940fe351bb19
tree9ab962f554730e7a2a60aed00f219af2952525d4
parente494ce760428cde79b63e9a9016c4af06484eef3

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.

1 files changed, 5 insertions(+), 1 deletions(-)

src/Compilation.zig+5-1
......@@ -3849,7 +3849,11 @@ fn setMiscFailure(
38493849) Allocator.Error!void {
38503850 try comp.misc_failures.ensureUnusedCapacity(comp.gpa, 1);
38513851 const msg = try std.fmt.allocPrint(comp.gpa, format, args);
3852 comp.misc_failures.putAssumeCapacityNoClobber(tag, .{ .msg = msg });
3852 const gop = comp.misc_failures.getOrPutAssumeCapacity(tag);
3853 if (gop.found_existing) {
3854 gop.value_ptr.deinit(comp.gpa);
3855 }
3856 gop.value_ptr.* = .{ .msg = msg };
38533857}
38543858
38553859pub fn dump_argv(argv: []const []const u8) void {