Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix interleaved output in the default panic hook when multiple threads panic simultaneously #127397

Merged
merged 2 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add test that multi-threaded panics aren't interleaved
  • Loading branch information
jyn514 committed Jul 5, 2024
commit de14f1f932f4f11130be3fed5cd370bd0936032e
15 changes: 15 additions & 0 deletions tests/ui/backtrace/synchronized-panic-handler.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//@ run-pass
//@ check-run-results
//@ edition:2021
use std::thread;
const PANIC_MESSAGE: &str = "oops oh no woe is me";

fn entry() {
panic!("{PANIC_MESSAGE}")
}

fn main() {
let (a, b) = (thread::spawn(entry), thread::spawn(entry));
assert_eq!(&**a.join().unwrap_err().downcast::<String>().unwrap(), PANIC_MESSAGE);
assert_eq!(&**b.join().unwrap_err().downcast::<String>().unwrap(), PANIC_MESSAGE);
}
5 changes: 5 additions & 0 deletions tests/ui/backtrace/synchronized-panic-handler.run.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
thread '<unnamed>' panicked at $DIR/synchronized-panic-handler.rs:thread '8<unnamed>: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:
oops oh no woe is me