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

Avoid allocation in the signal handler to fix a deadlock #24890

Merged
merged 3 commits into from Nov 27, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Only print a backtrace the first time the signal handler is called.

This avoids infinite recursion if the printing causes another signal.
  • Loading branch information
SimonSapin committed Nov 27, 2019
commit 99804eb5a6a6c2f4b1384f735cc43f2cc8b61b4f
@@ -31,7 +31,6 @@ use servo::servo_config::pref;
use std::env;
use std::panic;
use std::process;
use std::sync::atomic;
use std::thread;

pub mod platform {
@@ -55,12 +54,16 @@ fn install_crash_handler() {
use std::thread;

extern "C" fn handler(sig: i32) {
print!("Stack trace");
if let Some(name) = thread::current().name() {
print!(" for thread \"{}\"", name);
use std::sync::atomic;
static BEEN_HERE_BEFORE: atomic::AtomicBool = atomic::AtomicBool::new(false);
if !BEEN_HERE_BEFORE.swap(true, atomic::Ordering::SeqCst) {
print!("Stack trace");
if let Some(name) = thread::current().name() {
print!(" for thread \"{}\"", name);
}
println!();
backtrace::print();
}
println!();
backtrace::print();
unsafe {
_exit(sig);
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.