Created
October 17, 2019 22:15
-
-
Save comex/401f5c02f066fdea8e06c75a28267247 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[allow(non_camel_case_types)] | |
type pthread_t = usize; | |
extern { | |
fn pthread_testcancel(); | |
fn pthread_self() -> pthread_t; | |
fn pthread_cancel(pt: pthread_t) -> i32; | |
} | |
struct NoisyDrop; | |
impl Drop for NoisyDrop { | |
fn drop(&mut self) { | |
println!("NoisyDrop dropped"); | |
} | |
} | |
fn test() { | |
let _noisy_drop = NoisyDrop; | |
unsafe { | |
pthread_cancel(pthread_self()); | |
pthread_testcancel(); | |
} | |
println!("not canceled!?"); | |
} | |
fn main() { | |
std::thread::spawn(test).join().expect("did not join"); | |
println!("did join"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
On i686-unknown-linux-gnu: | |
$ rustc +stable boop.rs -C panic=unwind | |
$ ./boop | |
NoisyDrop dropped | |
FATAL: exception not rethrown | |
Aborted | |
$ rustc +stable boop.rs -C panic=abort | |
$ ./boop | |
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21 | |
stack backtrace: | |
0: backtrace::backtrace::libunwind::trace | |
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/libunwind.rs:88 | |
1: backtrace::backtrace::trace_unsynchronized | |
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/mod.rs:66 | |
2: std::sys_common::backtrace::_print | |
at src/libstd/sys_common/backtrace.rs:47 | |
3: std::sys_common::backtrace::print | |
at src/libstd/sys_common/backtrace.rs:36 | |
4: std::panicking::default_hook::{{closure}} | |
at src/libstd/panicking.rs:200 | |
5: std::panicking::default_hook | |
at src/libstd/panicking.rs:214 | |
6: std::panicking::rust_panic_with_hook | |
at src/libstd/panicking.rs:477 | |
7: std::panicking::continue_panic_fmt | |
at src/libstd/panicking.rs:384 | |
8: rust_begin_unwind | |
at src/libstd/panicking.rs:311 | |
9: core::panicking::panic_fmt | |
at src/libcore/panicking.rs:85 | |
10: core::panicking::panic | |
at src/libcore/panicking.rs:49 | |
11: core::option::Option<T>::unwrap | |
12: std::thread::JoinInner<T>::join | |
On macOS: | |
$ rustc +stable boop.rs -C panic=unwind | |
$ ./boop | |
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21 | |
stack backtrace: | |
0: std::panicking::default_hook::{{closure}} | |
1: std::panicking::default_hook | |
2: std::panicking::rust_panic_with_hook | |
3: std::panicking::continue_panic_fmt | |
4: rust_begin_unwind | |
5: core::panicking::panic_fmt | |
6: core::panicking::panic | |
7: core::option::Option<T>::unwrap | |
8: std::thread::JoinInner<T>::join | |
9: std::thread::JoinHandle<T>::join | |
10: boop::main | |
11: std::rt::lang_start::{{closure}} | |
12: std::panicking::try::do_call | |
13: __rust_maybe_catch_panic | |
14: std::rt::lang_start_internal | |
15: std::rt::lang_start | |
16: main | |
$ rustc +stable boop.rs -C panic=abort | |
$ ./boop | |
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21 | |
stack backtrace: | |
0: std::panicking::default_hook::{{closure}} | |
1: std::panicking::default_hook | |
2: std::panicking::rust_panic_with_hook | |
3: std::panicking::continue_panic_fmt | |
4: rust_begin_unwind | |
5: core::panicking::panic_fmt | |
6: core::panicking::panic | |
7: core::option::Option<T>::unwrap | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment