@@ -64,9 +64,8 @@ use prelude::v1::*;
64
64
65
65
use any:: Any ;
66
66
use boxed;
67
- use cell:: Cell ;
68
67
use cmp;
69
- use panicking;
68
+ use panicking:: { self , PANIC_COUNT } ;
70
69
use fmt;
71
70
use intrinsics;
72
71
use mem;
@@ -92,8 +91,6 @@ pub mod imp;
92
91
#[ path = "gcc.rs" ] #[ doc( hidden) ]
93
92
pub mod imp;
94
93
95
- thread_local ! { static PANICKING : Cell <bool > = Cell :: new( false ) }
96
-
97
94
/// Invoke a closure, capturing the cause of panic if one occurs.
98
95
///
99
96
/// This function will return `Ok(())` if the closure did not panic, and will
@@ -131,9 +128,9 @@ pub unsafe fn try<F: FnOnce()>(f: F) -> Result<(), Box<Any + Send>> {
131
128
// care of exposing correctly.
132
129
unsafe fn inner_try ( f : fn ( * mut u8 ) , data : * mut u8 )
133
130
-> Result < ( ) , Box < Any + Send > > {
134
- PANICKING . with ( |s| {
131
+ PANIC_COUNT . with ( |s| {
135
132
let prev = s. get ( ) ;
136
- s. set ( false ) ;
133
+ s. set ( 0 ) ;
137
134
let ep = intrinsics:: try ( f, data) ;
138
135
s. set ( prev) ;
139
136
if ep. is_null ( ) {
@@ -161,7 +158,7 @@ pub unsafe fn try<F: FnOnce()>(f: F) -> Result<(), Box<Any + Send>> {
161
158
162
159
/// Determines whether the current thread is unwinding because of panic.
163
160
pub fn panicking ( ) -> bool {
164
- PANICKING . with ( |s| s. get ( ) )
161
+ PANIC_COUNT . with ( |s| s. get ( ) != 0 )
165
162
}
166
163
167
164
// An uninlined, unmangled function upon which to slap yer breakpoints
@@ -234,17 +231,6 @@ fn begin_unwind_inner(msg: Box<Any + Send>,
234
231
// First, invoke the default panic handler.
235
232
panicking:: on_panic ( & * msg, file, line) ;
236
233
237
- if panicking ( ) {
238
- // If a thread panics while it's already unwinding then we
239
- // have limited options. Currently our preference is to
240
- // just abort. In the future we may consider resuming
241
- // unwinding or otherwise exiting the thread cleanly.
242
- super :: util:: dumb_print ( format_args ! ( "thread panicked while panicking. \
243
- aborting.") ) ;
244
- unsafe { intrinsics:: abort ( ) }
245
- }
246
- PANICKING . with ( |s| s. set ( true ) ) ;
247
-
248
234
// Finally, perform the unwinding.
249
235
rust_panic ( msg) ;
250
236
}
0 commit comments