Repository navigation
Description
When running the tests\ui\runtime\backtrace-debuginfo.rs test again aarch64-pc-windows-msvc, the test fails because the backtrace has been truncated:
thread 'main' panicked at C:\repos\rust\tests\ui\runtime\backtrace-debuginfo.rs:114:9:
explicit panic
stack backtrace:
0: 0x7ff91fe0d544 - std::backtrace_rs::backtrace::win64::trace
at C:\repos\rust\library\backtrace\src\backtrace\win64.rs:85
1: 0x7ff91fe0d544 - std::backtrace_rs::backtrace::trace_unsynchronized<std::sys::backtrace::_print_fmt::closure_env$1>
at C:\repos\rust\library\backtrace\src\backtrace\mod.rs:66
2: 0x7ff91fde5510 - std::sys::backtrace::_print_fmt
at C:\repos\rust\library\std\src\sys\backtrace.rs:66
3: 0x7ff91fde5510 - std::sys::backtrace::impl$0::print::impl$0::fmt
at C:\repos\rust\library\std\src\sys\backtrace.rs:39
4: 0x7ff91fe2264c - core::fmt::write
at C:\repos\rust\library\core\src\fmt\mod.rs:1481
5: 0x7ff91fddbeac - std::io::default_write_fmt<std::sys::stdio::windows::Stderr>
at C:\repos\rust\library\std\src\io\mod.rs:639
6: 0x7ff91fdcf11c - std::io::Write::write_fmt<std::sys::stdio::windows::Stderr>
at C:\repos\rust\library\std\src\io\mod.rs:1914
7: 0x7ff91fde540c - std::sys::backtrace::BacktraceLock::print
at C:\repos\rust\library\std\src\sys\backtrace.rs:42
8: 0x7ff91fe04364 - std::panicking::default_hook::closure$0
at C:\repos\rust\library\std\src\panicking.rs:300
9: 0x7ff91fe04184 - std::panicking::default_hook
at C:\repos\rust\library\std\src\panicking.rs:327
10: 0x7ff91fe04b5c - std::panicking::rust_panic_with_hook
at C:\repos\rust\library\std\src\panicking.rs:833
11: 0x7ff91fde5bf4 - std::panicking::begin_panic::closure$0<ref$<str$> >
at C:\repos\rust\library\std\src\panicking.rs:770
Digging into this further, the issue appears to be that the call to RtlVirtualUnwind stops after unwinding after std::panicking::begin_panic::closure$0<ref$<str$> > because the function reported by RtlLookupFunctionEntry is incorrect.
RtlLookupFunctionEntry seems to be getting confused as std::panicking::begin_panic::closure$0<ref$<str$> > is a non-returning function where its last instruction is to branch to another non-returning function. Thus, the return address reported from rust_panic_with_hook is actually after the end of std::panicking::begin_panic::closure$0<ref$<str$> >:
0:000> u 0x7ff91fde5bf0
std_b6e0767fb633a355!std::panicking::begin_panic::closure$0<ref$<str$> >+0x2c [C:\repos\rust\library\std\src\panicking.rs @ 770]:
00007ff9`1fde5bf0 94007ba1 bl std_b6e0767fb633a355!std::panicking::rust_panic_with_hook (00007ff9`1fe04a74)
std_b6e0767fb633a355!std::sys::pal::windows::pipe::anon_pipe [C:\repos\rust\library\std\src\sys\pal\windows\pipe.rs @ 59]:
00007ff`91fde5bf0 d10583ff sub sp,sp,#0x160
We might need to, somehow, get LLVM to add some padding for this case.
Activity
bjorn3 commentedon Apr 30, 2025
Is rust responsible for calling
RtlLookupFunctionEntry? If so can we subtract 1 from the return address before doing the lookup? That is what we do for looking up the function name with DWARF: https://github.com/rust-lang/backtrace-rs/blob/903c10db222c24b3e0fd085dfb0523abff192c5c/src/symbolize/mod.rs#L123-L147ChrisDenton commentedon Apr 30, 2025
Yes.
dpaoliello commentedon Apr 30, 2025
I'll do some experiments with this later, for now I'm documenting it as I try to stand up the Arm64 Windows runner.
@rustbot claim
Rollup merge of rust-lang#140755 - dpaoliello:arm64windebuginfo, r=ji…
Rollup merge of rust-lang#140755 - dpaoliello:arm64windebuginfo, r=ji…
Rollup merge of rust-lang#140755 - dpaoliello:arm64windebuginfo, r=ji…
Unrolled build for rust-lang#140755
dpaoliello commentedon Oct 28, 2025
FYI, looks like the correct thing to do here is for LLVM to generate
MSFT_OP_CLEAR_UNWOUND_TO_CALLunwind codes for these cases: this will instructRtlVirtualUnwindto look at the previous instruction. Not sure when I'll get around to implementing this...dpaoliello commentedon Feb 26, 2026
Talked to other folks at Microsoft:
MSFT_OP_CLEAR_UNWOUND_TO_CALLis the wrong solution to this. Their guess is that LLVM isn't generating abrkafter the call to thenoreturnfunction, which is required both to make unwinding work and for security.Rollup merge of rust-lang#153202 - dpaoliello:arm64unwind, r=cuviper
Rollup merge of rust-lang#153202 - dpaoliello:arm64unwind, r=cuviper
Unrolled build for #153202