Open
Description
I'm compiling this code on Windows with cargo build --release
use std::panic::{self, PanicInfo};
use std::process::abort;
#[inline(never)]
#[cold]
fn panic_handler(_panic_info: &PanicInfo<'_>) {
// Put something in so this doesn't get folded
println!("panic_handler");
abort();
}
#[inline(never)]
fn main() {
panic::set_hook(Box::new(panic_handler));
panic!("Fail");
}
When debugging, I see the following call stack (in WinDbg):
0:000> k
# Child-SP RetAddr Call Site
00 0000009e`ab37f400 00007ff7`d1be1069 hello!_guard_xfg_dispatch_icall_nop+0x4c
01 0000009e`ab37f460 00007ff7`d1be8f23 hello!ZN3std2rt10lang_start17h637565803574acbaE+0x59
02 (Inline Function) --------`-------- hello!alloc::boxed::impl$49::call+0xe [/rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library\alloc\src\boxed.rs @ 2021]
03 0000009e`ab37f490 00007ff7`d1be8d8b hello!std::panicking::rust_panic_with_hook+0x113 [/rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library\std\src\panicking.rs @ 786]
04 0000009e`ab37f570 00007ff7`d1be7509 hello!std::panicking::begin_panic_handler::closure$0+0x7b [/rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library\std\src\panicking.rs @ 649]
05 0000009e`ab37f5e0 00007ff7`d1be8ad4 hello!std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>+0x9 [/rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library\std\src\sys_common\backtrace.rs @ 170]
06 0000009e`ab37f610 00007ff7`d1bf9dc7 hello!std::panicking::begin_panic_handler+0x44 [/rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library\std\src\panicking.rs @ 645]
07 0000009e`ab37f650 00007ff7`d1be10cf hello!core::panicking::panic_fmt+0x37 [/rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library\core\src\panicking.rs @ 72]
08 0000009e`ab37f6a0 00007ff7`d1be1006 hello!ZN3std2rt10lang_start17h637565803574acbaE+0xbf
09 0000009e`ab37f700 00007ff7`d1be104c hello!__ImageBase
0a 0000009e`ab37f730 00007ff7`d1be3058 hello!ZN3std2rt10lang_start17h637565803574acbaE+0x3c
0b (Inline Function) --------`-------- hello!std::rt::lang_start_internal::closure$2+0xb [/rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library\std\src\rt.rs @ 148]
0c (Inline Function) --------`-------- hello!std::panicking::try::do_call+0xb [/rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library\std\src\panicking.rs @ 552]
0d (Inline Function) --------`-------- hello!std::panicking::try+0xb [/rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library\std\src\panicking.rs @ 516]
0e (Inline Function) --------`-------- hello!std::panic::catch_unwind+0xb [/rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library\std\src\panic.rs @ 142]
0f 0000009e`ab37f760 00007ff7`d1be1038 hello!std::rt::lang_start_internal+0xb8 [/rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library\std\src\rt.rs @ 148]
10 0000009e`ab37f870 00007ff7`d1bf8880 hello!ZN3std2rt10lang_start17h637565803574acbaE+0x28
11 (Inline Function) --------`-------- hello!invoke_main+0x22 [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 78]
Note that the top of the stack is _guard_xfg_dispatch_icall_nop. If we disassemble that function, we can see:
hello!_guard_xfg_dispatch_icall_nop+0xf:
00007ff7`d1bf926f cc int 3
00007ff7`d1bf9270 4883ec58 sub rsp,58h
00007ff7`d1bf9274 488d0525210000 lea rax,[hello!__xt_z+0x48 (00007ff7`d1bfb3a0)]
00007ff7`d1bf927b 4889442428 mov qword ptr [rsp+28h],rax
00007ff7`d1bf9280 48c744243001000000 mov qword ptr [rsp+30h],1
00007ff7`d1bf9289 488d0500210000 lea rax,[hello!__xt_z+0x38 (00007ff7`d1bfb390)]
00007ff7`d1bf9290 4889442438 mov qword ptr [rsp+38h],rax
00007ff7`d1bf9295 0f57c0 xorps xmm0,xmm0
00007ff7`d1bf9298 0f11442440 movups xmmword ptr [rsp+40h],xmm0
00007ff7`d1bf929d 488d4c2428 lea rcx,[rsp+28h]
00007ff7`d1bf92a2 e869bafeff call hello!std::io::stdio::_print (00007ff7`d1be4d10)
00007ff7`d1bf92a7 b907000000 mov ecx,7
00007ff7`d1bf92ac cd29 int 29h
Note that the exception is at the fastfail at 00007ff7d1bf92ac (inlined from std::process::abort() ), and the function start should be at 00007ff7d1bf9270. There is however, no symbol at that address.
0:000> ln 00007ff7`d1bf9270
Browse module
Set bu breakpoint
(00007ff7`d1bf9260) hello!_guard_xfg_dispatch_icall_nop+0x10 | (00007ff7`d1bf92b0) hello!core::str::pattern::simd_contains::closure$2
There is a function entry for the code however:
0:000> .fnent 00007ff7`d1bf9270
Debugger function entry 00000184`6bcdb9b0 for:
(00007ff7`d1bf9260) hello!_guard_xfg_dispatch_icall_nop+0x10 | (00007ff7`d1bf92b0) hello!core::str::pattern::simd_contains::closure$2
BeginAddress = 00000000`00019270
EndAddress = 00000000`000192b0
UnwindInfoAddress = 00000000`00020a28
Unwind info at 00007ff7`d1c00a28, 6 bytes
version 1, flags 0, prolog 4, codes 1
00: offs 4, unwind op 2, op info a UWOP_ALLOC_SMALL.
rustc --version --verbose
:
❯ rustc --version --verbose
rustc 1.75.0 (82e1608df 2023-12-21)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: x86_64-pc-windows-msvc
release: 1.75.0
LLVM version: 17.0.6