Skip to content

Commit 1c89f0d

Browse files
committed
---
yaml --- r: 232253 b: refs/heads/auto c: c6d277a h: refs/heads/master i: 232251: 743999b v: v3
1 parent a7cd3b0 commit 1c89f0d

File tree

2 files changed

+3
-70
lines changed

2 files changed

+3
-70
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: cbfa61282fc34204b9b66554e06189c2d0b4d085
11+
refs/heads/auto: c6d277ade642a8cf166d6e4706add90fb9181ec2
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/libstd/sys/common/unwind/mod.rs

Lines changed: 2 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -92,23 +92,6 @@ pub mod imp;
9292
#[path = "gcc.rs"] #[doc(hidden)]
9393
pub mod imp;
9494

95-
pub type Callback = fn(msg: &(Any + Send), file: &'static str, line: u32);
96-
97-
// Variables used for invoking callbacks when a thread starts to unwind.
98-
//
99-
// For more information, see below.
100-
const MAX_CALLBACKS: usize = 16;
101-
static CALLBACKS: [atomic::AtomicUsize; MAX_CALLBACKS] =
102-
[atomic::AtomicUsize::new(0), atomic::AtomicUsize::new(0),
103-
atomic::AtomicUsize::new(0), atomic::AtomicUsize::new(0),
104-
atomic::AtomicUsize::new(0), atomic::AtomicUsize::new(0),
105-
atomic::AtomicUsize::new(0), atomic::AtomicUsize::new(0),
106-
atomic::AtomicUsize::new(0), atomic::AtomicUsize::new(0),
107-
atomic::AtomicUsize::new(0), atomic::AtomicUsize::new(0),
108-
atomic::AtomicUsize::new(0), atomic::AtomicUsize::new(0),
109-
atomic::AtomicUsize::new(0), atomic::AtomicUsize::new(0)];
110-
static CALLBACK_CNT: atomic::AtomicUsize = atomic::AtomicUsize::new(0);
111-
11295
thread_local! { static PANICKING: Cell<bool> = Cell::new(false) }
11396

11497
/// Invoke a closure, capturing the cause of panic if one occurs.
@@ -249,29 +232,6 @@ fn begin_unwind_inner(msg: Box<Any + Send>,
249232
// First, invoke the default panic handler.
250233
panicking::on_panic(&*msg, file, line);
251234

252-
// Then, invoke call the user-defined callbacks triggered on thread panic.
253-
//
254-
// By the time that we see a callback has been registered (by reading
255-
// MAX_CALLBACKS), the actual callback itself may have not been stored yet,
256-
// so we just chalk it up to a race condition and move on to the next
257-
// callback. Additionally, CALLBACK_CNT may briefly be higher than
258-
// MAX_CALLBACKS, so we're sure to clamp it as necessary.
259-
let callbacks = {
260-
let amt = CALLBACK_CNT.load(Ordering::SeqCst);
261-
&CALLBACKS[..cmp::min(amt, MAX_CALLBACKS)]
262-
};
263-
for cb in callbacks {
264-
match cb.load(Ordering::SeqCst) {
265-
0 => {}
266-
n => {
267-
let f: Callback = unsafe { mem::transmute(n) };
268-
f(&*msg, file, line);
269-
}
270-
}
271-
};
272-
273-
// Now that we've run all the necessary unwind callbacks, we actually
274-
// perform the unwinding.
275235
if panicking() {
276236
// If a thread panics while it's already unwinding then we
277237
// have limited options. Currently our preference is to
@@ -282,34 +242,7 @@ fn begin_unwind_inner(msg: Box<Any + Send>,
282242
unsafe { intrinsics::abort() }
283243
}
284244
PANICKING.with(|s| s.set(true));
285-
rust_panic(msg);
286-
}
287245

288-
/// Register a callback to be invoked when a thread unwinds.
289-
///
290-
/// This is an unsafe and experimental API which allows for an arbitrary
291-
/// callback to be invoked when a thread panics. This callback is invoked on both
292-
/// the initial unwinding and a double unwinding if one occurs. Additionally,
293-
/// the local `Thread` will be in place for the duration of the callback, and
294-
/// the callback must ensure that it remains in place once the callback returns.
295-
///
296-
/// Only a limited number of callbacks can be registered, and this function
297-
/// returns whether the callback was successfully registered or not. It is not
298-
/// currently possible to unregister a callback once it has been registered.
299-
pub unsafe fn register(f: Callback) -> bool {
300-
match CALLBACK_CNT.fetch_add(1, Ordering::SeqCst) {
301-
// The invocation code has knowledge of this window where the count has
302-
// been incremented, but the callback has not been stored. We're
303-
// guaranteed that the slot we're storing into is 0.
304-
n if n < MAX_CALLBACKS => {
305-
let prev = CALLBACKS[n].swap(mem::transmute(f), Ordering::SeqCst);
306-
rtassert!(prev == 0);
307-
true
308-
}
309-
// If we accidentally bumped the count too high, pull it back.
310-
_ => {
311-
CALLBACK_CNT.store(MAX_CALLBACKS, Ordering::SeqCst);
312-
false
313-
}
314-
}
246+
// Finally, perform the unwinding.
247+
rust_panic(msg);
315248
}

0 commit comments

Comments
 (0)