authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-09-25 19:34:34-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-09-26 12:35:14-07:00
log61b20105e43b0db6d6f459dcb42acdda0365e0a3
tree7e1dbdbedb51447276a53dbb5f404214f879745a
parent70746d580c7096938446eb47f57242edf17a9caf

fix crash report not using mutexes correctly


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

src/crash_report.zig+2-5
...@@ -321,9 +321,6 @@ const PanicSwitch = struct {...@@ -321,9 +321,6 @@ const PanicSwitch = struct {
321 /// until all panicking threads have dumped their traces.321 /// until all panicking threads have dumped their traces.
322 var panicking = std.atomic.Value(u8).init(0);322 var panicking = std.atomic.Value(u8).init(0);
323323
324 // Locked to avoid interleaving panic messages from multiple threads.
325 var panic_mutex = std.Thread.Mutex{};
326
327 /// Tracks the state of the current panic. If the code within the324 /// Tracks the state of the current panic. If the code within the
328 /// panic triggers a secondary panic, this allows us to recover.325 /// panic triggers a secondary panic, this allows us to recover.
329 threadlocal var panic_state_raw: PanicState = .{};326 threadlocal var panic_state_raw: PanicState = .{};
...@@ -391,7 +388,7 @@ const PanicSwitch = struct {...@@ -391,7 +388,7 @@ const PanicSwitch = struct {
391388
392 state.recover_stage = .release_ref_count;389 state.recover_stage = .release_ref_count;
393390
394 panic_mutex.lock();391 std.debug.lockStdErr();
395392
396 state.recover_stage = .release_mutex;393 state.recover_stage = .release_mutex;
397394
...@@ -453,7 +450,7 @@ const PanicSwitch = struct {...@@ -453,7 +450,7 @@ const PanicSwitch = struct {
453 noinline fn releaseMutex(state: *volatile PanicState) noreturn {450 noinline fn releaseMutex(state: *volatile PanicState) noreturn {
454 state.recover_stage = .abort;451 state.recover_stage = .abort;
455452
456 panic_mutex.unlock();453 std.debug.unlockStdErr();
457454
458 goTo(releaseRefCount, .{state});455 goTo(releaseRefCount, .{state});
459 }456 }