Skip to content

Commit 57572cf

Browse files
committed
Call into fastfail on abort in libpanic_abort on Windows x86(_64)
1 parent 13290e8 commit 57572cf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

library/panic_abort/src/lib.rs

+14
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#![feature(panic_runtime)]
1818
#![feature(staged_api)]
1919
#![feature(rustc_attrs)]
20+
#![feature(llvm_asm)]
2021

2122
use core::any::Any;
2223

@@ -55,6 +56,19 @@ pub unsafe extern "C" fn __rust_start_panic(_payload: usize) -> u32 {
5556
}
5657
__rust_abort();
5758
}
59+
} else if #[cfg(all(windows, any(target_arch = "x86", target_arch = "x86_64")))] {
60+
// On Windows, use the processor-specific __fastfail mechanism. In Windows 8
61+
// and later, this will terminate the process immediately without running any
62+
// in-process exception handlers. In earlier versions of Windows, this
63+
// sequence of instructions will be treated as an access violation,
64+
// terminating the process but without necessarily bypassing all exception
65+
// handlers.
66+
//
67+
// https://docs.microsoft.com/en-us/cpp/intrinsics/fastfail
68+
unsafe fn abort() -> ! {
69+
llvm_asm!("int $$0x29" :: "{ecx}"(7) ::: volatile); // 7 is FAST_FAIL_FATAL_APP_EXIT
70+
core::intrinsics::unreachable();
71+
}
5872
} else {
5973
unsafe fn abort() -> ! {
6074
core::intrinsics::abort();

0 commit comments

Comments
 (0)