Skip to content

Failed to capture backtrace when compiling with --remap-path-prefix=${PWD}= #135853

Open
@ashi009

Description

@ashi009

I tried this code:

fn main() {
    panic!("oh no!");
}

I expected to see this happen: backtrace_rs::main yields correct remapped source info.

$ RUST_BACKTRACE=1 cargo run
thread 'main' panicked at src/main.rs:2:5:
oh no!
stack backtrace:
   0: rust_begin_unwind
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:662:5
   1: core::panicking::panic_fmt
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panicking.rs:74:14
   2: backtrace_rs::main
             at src/main.rs:2:5
   3: core::ops::function::FnOnce::call_once
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Instead, this happened: source info for 2-3 are missing.

$ RUSTFLAGS="--remap-path-prefix=$(pwd)=" RUST_BACKTRACE=1 cargo run
thread 'main' panicked at src/main.rs:2:5:
oh no!
stack backtrace:
   0: rust_begin_unwind
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:662:5
   1: core::panicking::panic_fmt
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panicking.rs:74:14
   2: backtrace_rs::main
   3: core::ops::function::FnOnce::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Meta

rustc --version --verbose:

rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: aarch64-apple-darwin
release: 1.82.0
LLVM version: 19.1.1

also checked:

rustc +nightly-aarch64-apple-darwin --version --verbose:

rustc 1.86.0-nightly (f3d1d47fd 2025-01-20)
binary: rustc
commit-hash: f3d1d47fd84dfcf7f513be1dbad356e74c8f3b2b
commit-date: 2025-01-20
host: aarch64-apple-darwin
release: 1.86.0-nightly
LLVM version: 19.1.7

This is also reported to rust-lang/backtrace-rs#691.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-backtraceArea: BacktracesA-path-remappingArea: path remapping, --remap-path-prefix, --remap-cwd-prefix, --remap-diagnostics-scope etc.C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions