From 1c8f9bb84d5956abe6671bf77ccaba64505266a5 Mon Sep 17 00:00:00 2001 From: jyn Date: Fri, 5 Jul 2024 17:24:10 -0400 Subject: fix interleaved panic output previously, we only held a lock for printing the backtrace itself. since all threads were printing to the same file descriptor, that meant random output in the default panic hook would be interleaved with the backtrace. now, we hold the lock for the full duration of the hook, and the output is ordered. --- tests/ui/backtrace/synchronized-panic-handler.rs | 2 ++ tests/ui/backtrace/synchronized-panic-handler.run.stderr | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'tests/ui/backtrace') diff --git a/tests/ui/backtrace/synchronized-panic-handler.rs b/tests/ui/backtrace/synchronized-panic-handler.rs index 0ea285968d5..00eb249da1d 100644 --- a/tests/ui/backtrace/synchronized-panic-handler.rs +++ b/tests/ui/backtrace/synchronized-panic-handler.rs @@ -1,6 +1,8 @@ //@ run-pass //@ check-run-results //@ edition:2021 +//@ exec-env:RUST_BACKTRACE=0 +//@ needs-threads use std::thread; const PANIC_MESSAGE: &str = "oops oh no woe is me"; diff --git a/tests/ui/backtrace/synchronized-panic-handler.run.stderr b/tests/ui/backtrace/synchronized-panic-handler.run.stderr index 06ef53836c2..b7c815a94c8 100644 --- a/tests/ui/backtrace/synchronized-panic-handler.run.stderr +++ b/tests/ui/backtrace/synchronized-panic-handler.run.stderr @@ -1,5 +1,5 @@ -thread '' panicked at $DIR/synchronized-panic-handler.rs:thread '8:5' panicked at : -oops oh no woe is me$DIR/synchronized-panic-handler.rs -:note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -8:5: +thread '' panicked at $DIR/synchronized-panic-handler.rs:10:5: +oops oh no woe is me +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +thread '' panicked at $DIR/synchronized-panic-handler.rs:10:5: oops oh no woe is me -- cgit 1.4.1-3-g733a5