From f5c9d56c336cf52b18035412a3e4f5bb2ab5147b Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 8 Apr 2016 18:31:31 +0000 Subject: [PATCH] std: Funnel all aborts through rtabort! cc #31519 --- src/libstd/panicking.rs | 11 ++++------- src/libstd/sys/common/unwind/seh.rs | 2 +- src/libstd/sys/unix/mod.rs | 3 +-- src/libstd/sys/windows/mod.rs | 3 +-- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index fd6a15b0f69a3..98c0071b6454b 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -14,7 +14,6 @@ use io::prelude::*; use any::Any; use cell::Cell; use cell::RefCell; -use intrinsics; use sync::StaticRwLock; use sync::atomic::{AtomicBool, Ordering}; use sys::stdio::Stderr; @@ -208,9 +207,8 @@ pub fn on_panic(obj: &(Any+Send), file: &'static str, line: u32) { // abort immediately to avoid infinite recursion, so that attaching a // debugger provides a useable stacktrace. if panics >= 3 { - util::dumb_print(format_args!("thread panicked while processing \ - panic. aborting.\n")); - unsafe { intrinsics::abort() } + rtabort!("thread panicked while processing \ + panic. aborting."); } let info = PanicInfo { @@ -234,8 +232,7 @@ pub fn on_panic(obj: &(Any+Send), file: &'static str, line: u32) { // have limited options. Currently our preference is to // just abort. In the future we may consider resuming // unwinding or otherwise exiting the thread cleanly. - util::dumb_print(format_args!("thread panicked while panicking. \ - aborting.\n")); - unsafe { intrinsics::abort() } + rtabort!("thread panicked while panicking. \ + aborting."); } } diff --git a/src/libstd/sys/common/unwind/seh.rs b/src/libstd/sys/common/unwind/seh.rs index 94da42f0092f5..842732d0a74c3 100644 --- a/src/libstd/sys/common/unwind/seh.rs +++ b/src/libstd/sys/common/unwind/seh.rs @@ -149,5 +149,5 @@ mod imp { #[lang = "eh_personality"] #[cfg(not(test))] fn rust_eh_personality() { - unsafe { ::intrinsics::abort() } + rtabort!() } diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index f8b2d4dd23240..2f3b6a24090e1 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -73,13 +73,12 @@ pub fn init() { // errors are ignored while printing since there's nothing we can do about // them and we are about to exit anyways. fn oom_handler() -> ! { - use intrinsics; let msg = "fatal runtime error: out of memory\n"; unsafe { libc::write(libc::STDERR_FILENO, msg.as_ptr() as *const libc::c_void, msg.len() as libc::size_t); - intrinsics::abort(); + rtabort!(); } } diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs index 384940e4dc446..debd48e2433fe 100644 --- a/src/libstd/sys/windows/mod.rs +++ b/src/libstd/sys/windows/mod.rs @@ -48,7 +48,6 @@ pub fn init() { // See comment in sys/unix/mod.rs fn oom_handler() -> ! { - use intrinsics; use ptr; let msg = "fatal runtime error: out of memory\n"; unsafe { @@ -59,7 +58,7 @@ pub fn init() { msg.len() as c::DWORD, ptr::null_mut(), ptr::null_mut()); - intrinsics::abort(); + rtabort!(); } } }