aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-06-13 00:21:12 -0400
committerGitHub <noreply@github.com>2024-06-13 00:21:12 -0400
commit4aa15440c7a12bcc6bc0cd589ade02295549d48c (patch)
treeffbd491bd4ef97b9169dcfc89ba3c14b60cc03ef /lib/std/debug.zig
parent0cef727e59d7b0c34756c09f64cbfe4490dcc3e7 (diff)
parent5fc1f8a32bb7d66c0db04e497b89f7e33f408722 (diff)
downloadzig-4aa15440c7a12bcc6bc0cd589ade02295549d48c.tar.gz
zig-4aa15440c7a12bcc6bc0cd589ade02295549d48c.zip
Merge pull request #20268 from ziglang/keep-calm-and-continue-panicking
Diffstat (limited to 'lib/std/debug.zig')
-rw-r--r--lib/std/debug.zig15
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig
index f431d0eb91..e7d0d23766 100644
--- a/lib/std/debug.zig
+++ b/lib/std/debug.zig
@@ -447,9 +447,6 @@ pub fn panicExtra(
/// The counter is incremented/decremented atomically.
var panicking = std.atomic.Value(u8).init(0);
-// Locked to avoid interleaving panic messages from multiple threads.
-var panic_mutex = std.Thread.Mutex{};
-
/// Counts how many times the panic handler is invoked by this thread.
/// This is used to catch and handle panics triggered by the panic handler.
threadlocal var panic_stage: usize = 0;
@@ -474,8 +471,8 @@ pub fn panicImpl(trace: ?*const std.builtin.StackTrace, first_trace_addr: ?usize
// Make sure to release the mutex when done
{
- panic_mutex.lock();
- defer panic_mutex.unlock();
+ lockStdErr();
+ defer unlockStdErr();
const stderr = io.getStdErr().writer();
if (builtin.single_threaded) {
@@ -2604,8 +2601,8 @@ fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopa
_ = panicking.fetchAdd(1, .seq_cst);
{
- panic_mutex.lock();
- defer panic_mutex.unlock();
+ lockStdErr();
+ defer unlockStdErr();
dumpSegfaultInfoPosix(sig, code, addr, ctx_ptr);
}
@@ -2680,8 +2677,8 @@ fn handleSegfaultWindowsExtra(
_ = panicking.fetchAdd(1, .seq_cst);
{
- panic_mutex.lock();
- defer panic_mutex.unlock();
+ lockStdErr();
+ defer unlockStdErr();
dumpSegfaultInfoWindows(info, msg, label);
}