mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Only print a backtrace the first time the signal handler is called.
This avoids infinite recursion if the printing causes another signal.
This commit is contained in:
parent
413f499da8
commit
99804eb5a6
1 changed files with 9 additions and 6 deletions
|
@ -31,7 +31,6 @@ use servo::servo_config::pref;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::panic;
|
use std::panic;
|
||||||
use std::process;
|
use std::process;
|
||||||
use std::sync::atomic;
|
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
pub mod platform {
|
pub mod platform {
|
||||||
|
@ -55,12 +54,16 @@ fn install_crash_handler() {
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
extern "C" fn handler(sig: i32) {
|
extern "C" fn handler(sig: i32) {
|
||||||
print!("Stack trace");
|
use std::sync::atomic;
|
||||||
if let Some(name) = thread::current().name() {
|
static BEEN_HERE_BEFORE: atomic::AtomicBool = atomic::AtomicBool::new(false);
|
||||||
print!(" for thread \"{}\"", name);
|
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 {
|
unsafe {
|
||||||
_exit(sig);
|
_exit(sig);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue