Skip to content

Conversation

@eggyal
Copy link
Contributor

@eggyal eggyal commented Jan 27, 2026

Locate the beginning and ending frames for short backtraces by address in addition to symbol name, so that they work even when symbols have been stripped from the executable.

We need to retain matching by symbol name for the time being, because rustc (and some associated ui tests) rely upon it to have ICE backtraces abbreviated. They can be updated once this commit lands in beta/stage0. (It is for this reason that the begin/end methods are being publicly exported from std::backtrace, albeit hidden from documentation and marked unstable).

Fixes #147846
r? libs

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 27, 2026
@rust-log-analyzer

This comment has been minimized.

@eggyal eggyal force-pushed the short-backtrace-markers-by-addr branch from 53c0426 to f857f07 Compare January 27, 2026 15:28
@rust-log-analyzer

This comment has been minimized.

@eggyal eggyal force-pushed the short-backtrace-markers-by-addr branch from f857f07 to 6605497 Compare January 27, 2026 15:51
@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Jan 27, 2026

The Miri subtree was changed

cc @rust-lang/miri

@rust-log-analyzer

This comment has been minimized.

@jhpratt
Copy link
Member

jhpratt commented Jan 29, 2026

@rustbot reroll

@rustbot rustbot assigned joboet and unassigned jhpratt Jan 29, 2026
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 30, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 30, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

Locate the beginning and ending frames for short backtraces by address
in addition to symbol name, so that they work even when symbols have
been stripped from the executable.

We need to retain matching by symbol name for the time being, because
rustc (and some associated ui tests) rely upon it to have ICE backtraces
abbreviated.  They can be updated once this commit lands in beta/stage0.
@eggyal eggyal force-pushed the short-backtrace-markers-by-addr branch from c650ea2 to 6c5d59a Compare January 30, 2026 14:26
@eggyal
Copy link
Contributor Author

eggyal commented Jan 30, 2026

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 30, 2026
@rust-log-analyzer

This comment has been minimized.

@eggyal eggyal force-pushed the short-backtrace-markers-by-addr branch from 6c5d59a to 827da1d Compare January 30, 2026 18:08
@rust-log-analyzer

This comment has been minimized.

@eggyal
Copy link
Contributor Author

eggyal commented Jan 30, 2026

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 30, 2026
The new short backtrace markers place three frames in backtraces: the
marker initially invoked by downstream code (should be inlined into such
downstream code); the type-erased marker at a known-address (detected by
the backtrace printing code); and the type-restoring callback shim (into
which the actual callback should also be inlined).  This differs from
the status-quo ante, where the backtrace markers placed only a single
frame into backtraces.

Whilst these additional frames should have negligible impact on runtime
performance (not only are they called, by the language runtime, at most
twice: once during start before invoking main and once upon panic, if
any; but furthermore, due to the aforementioned inlining, optimized
assembly should be very similar - the additional frames will mostly only
arise from additional debug info), the expected outputs from some miri
tests require updating to reflect these backtrace changes.
This status-quo ante of this naked function test defined a label with
the symbolic name `.L7`.  However, changes to the stack could cause a
collision with that same symbolic name being defined by compiler-
generated code; therefore we use a local label instead to guarantee
collision avoidance.
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-miri failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
REPOSITORY                                   TAG       IMAGE ID       CREATED      SIZE
ghcr.io/dependabot/dependabot-updater-core   latest    bcec0b4e062b   4 days ago   783MB
=> Removing docker images...
Deleted Images:
untagged: ghcr.io/dependabot/dependabot-updater-core:latest
untagged: ghcr.io/dependabot/dependabot-updater-core@sha256:b662be51f7b8ef7e2c8464428f14e49cb79c36aa9afb7ecb9221dfe0f507050c
deleted: sha256:bcec0b4e062b5ffe11cc1c2729558c0cd96621c0271ab5e97ff3a56e0c25045a
deleted: sha256:64e147d5e54d9be8b8aa322e511cda02296eda4b8b8d063c6a314833aca50e29
deleted: sha256:5cba409bb463f4e7fa1a19f695450170422582c1bc7c0e934d893b4e5f558bc6
deleted: sha256:cddc6ebd344b0111eaab170ead1dfda24acdfe865ed8a12599a34d338fa8e28b
deleted: sha256:2412c3f334d79134573cd45e657fb6cc0abd75bef3881458b0d498d936545c8d
---
tests/panic/function_calls/exported_symbol_good_unwind.rs ... ok
tests/panic/panic1.rs ... FAILED

FAILED TEST: tests/panic/panic1.rs
command: MIRI_ENV_VAR_TEST="0" MIRI_TEMP="/tmp/miri-uitest-7HyGDk" RUST_BACKTRACE="1" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/miri" "--error-format=json" "--sysroot=/checkout/obj/build/x86_64-unknown-linux-gnu/miri-sysroot" "-Dwarnings" "-Dunused" "-Ainternal_features" "-Zui-testing" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/tmp/miri_ui/0/tests/panic" "tests/panic/panic1.rs" "-Zmiri-disable-isolation" "--extern" "cfg_if=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/libcfg_if-99831d7409c12b7d.rlib" "--extern" "cfg_if=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/libcfg_if-99831d7409c12b7d.rmeta" "--extern" "getrandom_01=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/libgetrandom-2b02165ee1bc0ba9.rlib" "--extern" "getrandom_01=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/libgetrandom-2b02165ee1bc0ba9.rmeta" "--extern" "getrandom_02=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/libgetrandom-5d222fad83b1ea62.rlib" "--extern" "getrandom_02=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/libgetrandom-5d222fad83b1ea62.rmeta" "--extern" "getrandom_03=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/libgetrandom-1b5d3639f2ce12ce.rlib" "--extern" "getrandom_03=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/libgetrandom-1b5d3639f2ce12ce.rmeta" "--extern" "libc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/liblibc-0f0eda93a6d228d0.rlib" "--extern" "libc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/liblibc-0f0eda93a6d228d0.rmeta" "--extern" "num_cpus=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/libnum_cpus-84f1655f49a0417f.rlib" "--extern" "num_cpus=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/libnum_cpus-84f1655f49a0417f.rmeta" "--extern" "futures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/libfutures-6ba8dd82973a1f29.rlib" "--extern" "futures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/libfutures-6ba8dd82973a1f29.rmeta" "--extern" "page_size=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/libpage_size-4cf52a5abb0dd411.rlib" "--extern" "page_size=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/libpage_size-4cf52a5abb0dd411.rmeta" "--extern" "tempfile=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/libtempfile-9c5590960aea7ab9.rlib" "--extern" "tempfile=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/libtempfile-9c5590960aea7ab9.rmeta" "--extern" "tokio=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/libtokio-87fcd788a09ed82c.rlib" "--extern" "tokio=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/libtokio-87fcd788a09ed82c.rmeta" "--extern" "windows_sys=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/libwindows_sys-8298680ec02acef7.rlib" "--extern" "windows_sys=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps/libwindows_sys-8298680ec02acef7.rmeta" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/i686-pc-windows-msvc/debug/deps" "-L" "native=/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/windows_i686_msvc-0.53.0/lib" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/debug/deps" "-L" "native=/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/windows_i686_msvc-0.52.6/lib" "-l" "dylib=kernel32" "-l" "advapi32" "--edition" "2021" "--target" "i686-pc-windows-msvc"

error: actual output differed from expected
Execute `./miri test --bless` to update `tests/panic/panic1.stderr` to the actual output
--- tests/panic/panic1.stderr
+++ <stderr output>
 
 thread 'main' ($TID) panicked at tests/panic/panic1.rs:LL:CC:
 panicking from libstd
 stack backtrace:
-   0: std::sys::backtrace::call_with_short_backtrace_marker
-             at RUSTLIB/std/src/sys/backtrace.rs:LL:CC
-   1: std::panicking::panic_handler
---
Location:
   /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ui_test-0.30.3/src/lib.rs:365

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   1: <color_eyre[7976d7541ad7c411]::config::EyreHook>::into_eyre_hook::{closure#0}<unknown>
      at <unknown source file>:<unknown line>
   2: <eyre[aba6084a4ce5f1dd]::Report>::from_adhoc::<&str><unknown>
      at <unknown source file>:<unknown line>
   3: ui_test[e5d7dadbbe08f07b]::run_tests_generic::<ui_test[e5d7dadbbe08f07b]::default_file_filter, ui[4f7328dbdce5d224]::run_tests::{closure#1}, alloc[ad6d6799f1736e43]::boxed::Box<dyn ui_test[e5d7dadbbe08f07b]::status_emitter::StatusEmitter>><unknown>
      at <unknown source file>:<unknown line>
   4: ui[4f7328dbdce5d224]::ui<unknown>
      at <unknown source file>:<unknown line>
   5: ui[4f7328dbdce5d224]::main<unknown>
      at <unknown source file>:<unknown line>
   6: std[93304be29ad7da0c]::sys::backtrace::__rust_begin_short_backtrace::<fn() -> core[65bd94dec34f9a3b]::result::Result<(), eyre[aba6084a4ce5f1dd]::Report>, core[65bd94dec34f9a3b]::result::Result<(), eyre[aba6084a4ce5f1dd]::Report>>::{closure#0}<unknown>
      at <unknown source file>:<unknown line>
   7: std[93304be29ad7da0c]::sys::backtrace::call_with_short_backtrace_marker::<std[93304be29ad7da0c]::sys::backtrace::Begin><unknown>
      at <unknown source file>:<unknown line>
   8: std[93304be29ad7da0c]::rt::lang_start::<core[65bd94dec34f9a3b]::result::Result<(), eyre[aba6084a4ce5f1dd]::Report>>::{closure#0}<unknown>
      at <unknown source file>:<unknown line>
   9: std[93304be29ad7da0c]::rt::lang_start_internal<unknown>
      at <unknown source file>:<unknown line>
  10: main<unknown>
      at <unknown source file>:<unknown line>
  11: __libc_start_main<unknown>
      at <unknown source file>:<unknown line>
  12: _start<unknown>
      at <unknown source file>:<unknown line>

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
Run with RUST_BACKTRACE=full to include source snippets.
error: test failed, to rerun pass `--test ui`

Caused by:
  process didn't exit successfully: `/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/ui-399d57cbacaa656d` (exit status: 1)
Bootstrap failed while executing `test --stage 2 src/tools/miri src/tools/miri/cargo-miri --target i686-pc-windows-msvc`
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo test -Zwarnings --target x86_64-unknown-linux-gnu -Zbinary-dep-depinfo -j 4 -Zroot-dir=/checkout --locked --color=always --profile=release --manifest-path /checkout/src/tools/miri/Cargo.toml -- [workdir=/checkout]` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:191:21
Executed at: src/bootstrap/src/core/build_steps/test.rs:738:19

Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:02:19
  local time: Fri Jan 30 22:21:05 UTC 2026
  network time: Fri, 30 Jan 2026 22:21:05 GMT
##[error]Process completed with exit code 1.
##[group]Run echo "disk usage:"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stripped executables don't print backtrace with RUST_BACKTRACE=1

6 participants