Call into fastfail on abort in libpanic_abort on Windows x86(_64)

This commit is contained in:
Ryan Levick 2020-08-10 14:08:31 +02:00
parent 13290e83a6
commit 57572cf809

View file

@ -17,6 +17,7 @@
#![feature(panic_runtime)]
#![feature(staged_api)]
#![feature(rustc_attrs)]
#![feature(llvm_asm)]
use core::any::Any;
@ -55,6 +56,19 @@ unsafe fn abort() -> ! {
}
__rust_abort();
}
} else if #[cfg(all(windows, any(target_arch = "x86", target_arch = "x86_64")))] {
// On Windows, use the processor-specific __fastfail mechanism. In Windows 8
// and later, this will terminate the process immediately without running any
// in-process exception handlers. In earlier versions of Windows, this
// sequence of instructions will be treated as an access violation,
// terminating the process but without necessarily bypassing all exception
// handlers.
//
// https://docs.microsoft.com/en-us/cpp/intrinsics/fastfail
unsafe fn abort() -> ! {
llvm_asm!("int $$0x29" :: "{ecx}"(7) ::: volatile); // 7 is FAST_FAIL_FATAL_APP_EXIT
core::intrinsics::unreachable();
}
} else {
unsafe fn abort() -> ! {
core::intrinsics::abort();