Skip to content

remap-path-prefix from 1.47.0 results in weird prefixes in backtraces #78479

Open
@Nemo157

Description

@Nemo157

I tried this code:

#![feature(backtrace)]

fn main() {
    futures::executor::block_on(async move {
        println!("{}", std::backtrace::Backtrace::capture());
        panic!()
    });
}

with the environment variables:

RUSTFLAGS='--remap-path-prefix=/home/nemo157/.cargo/registry/src/github.com-1ecc6299db9ec823=crates.io'
RUST_BACKTRACE=1
RUSTC_BOOTSTRAP=1

On 1.46 (and earlier) this results in backtraces looking as expected (for both the Backtrace::capture and begin_panic):

   5: std::thread::local::LocalKey<T>::with
             at /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/libstd/thread/local.rs:239
   6: futures_executor::local_pool::run_executor
             at crates.io/futures-executor-0.3.7/src/local_pool.rs:83
   7: futures_executor::local_pool::block_on
             at crates.io/futures-executor-0.3.7/src/local_pool.rs:317
   8: foo::main
             at src/main.rs:4

but on 1.47 and later there is a spurious ./ prefixed onto the remapped paths:

   6: std::thread::local::LocalKey<T>::with
             at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/thread/local.rs:241
   7: futures_executor::local_pool::run_executor
             at ./crates.io/futures-executor-0.3.7/src/local_pool.rs:83
   8: futures_executor::local_pool::block_on
             at ./crates.io/futures-executor-0.3.7/src/local_pool.rs:317
   9: foo::main
             at ./src/main.rs:4

If there are remapped frames on top of each other this seems to become even more complex, in another project using this set of flags:

rustflags = [
  "--remap-path-prefix=/home/nemo157=~",
  "--remap-path-prefix=/home/nemo157/.cargo=cargo",
  "--remap-path-prefix=/home/nemo157/.cargo/registry/src/github.com-1ecc6299db9ec823=crates.io",
  "--remap-path-prefix=/home/nemo157/.rustup=rustup",
]

I got a backtrace like this:

   8: clap::app::App::get_matches_from
             at crates.io/clap-2.33.3/crates.io/clap-2.33.3/src/app/mod.rs:1519:9
   9: clap::app::App::get_matches
             at crates.io/clap-2.33.3/crates.io/clap-2.33.3/src/app/mod.rs:1460:9
  10: structopt::StructOpt::from_args
             at ~/sources/bs58-rs/crates.io/structopt-0.3.18/src/lib.rs:1089:26
  11: <bs58::Args as paw_raw::ParseArgs>::parse_args
             at ~/sources/bs58-rs/cli/src/main.rs:69:17
  12: bs58::main
             at ~/sources/bs58-rs/cli/src/main.rs:83:1

Frames 8 and 9 include duplicate crates.io/clap-2.33.3 prefixes, and frame 10 randomly has a ~/sources/bs58-rs prefix

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-reproducibilityArea: Reproducible / deterministic buildsC-bugCategory: This is a bug.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions