Skip to content

Commit 426c00f

Browse files
committed
---
yaml --- r: 236329 b: refs/heads/master c: 54c0231 h: refs/heads/master i: 236327: 43bd5e6 v: v3
1 parent 55eb0c2 commit 426c00f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: c7b84909b00dcf5f762778b4aa9783770c69416d
2+
refs/heads/master: 54c0231b14a71a46e6607255d509457e0df0b8be
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
44
refs/heads/try: ea3892f76a2180dd4ce724f1dafd9186959702d9
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

trunk/src/libstd/panicking.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ fn log_panic(obj: &(Any+Send), file: &'static str, line: u32,
5252
let prev = LOCAL_STDERR.with(|s| s.borrow_mut().take());
5353
match (prev, err.as_mut()) {
5454
(Some(mut stderr), _) => {
55-
// FIXME: what to do when the thread printing panics?
5655
write(&mut *stderr);
5756
let mut s = Some(stderr);
5857
LOCAL_STDERR.with(|slot| {
@@ -71,6 +70,17 @@ pub fn on_panic(obj: &(Any+Send), file: &'static str, line: u32) {
7170
count
7271
});
7372

73+
// If this is the third nested call, on_panic triggered the last panic,
74+
// otherwise the double-panic check would have aborted the process.
75+
// Even if it is likely that on_panic was unable to log the backtrace,
76+
// abort immediately to avoid infinite recursion, so that attaching a
77+
// debugger provides a useable stacktrace.
78+
if panics >= 3 {
79+
util::dumb_print(format_args!("thread panicked while processing \
80+
panic. aborting."));
81+
unsafe { intrinsics::abort() }
82+
}
83+
7484
// If this is a double panic, make sure that we print a backtrace
7585
// for this panic. Otherwise only print it if logging is enabled.
7686
let log_backtrace = panics >= 2 || backtrace::log_enabled();

0 commit comments

Comments
 (0)