Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: rustdoc: attempted to remap an already remapped filename #138520

Closed
ojeda opened this issue Mar 14, 2025 · 0 comments · Fixed by #138556
Closed

ICE: rustdoc: attempted to remap an already remapped filename #138520

ojeda opened this issue Mar 14, 2025 · 0 comments · Fixed by #138556
Labels
A-path-remapping Area: path remapping, --remap-path-prefix, --remap-cwd-prefix, --remap-diagnostics-scope etc. A-rust-for-linux Relevant for the Rust-for-Linux project C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@ojeda
Copy link
Contributor

ojeda commented Mar 14, 2025

Code

echo 'macro_rules! f(() => {});' > x.rs
RUSTC_BOOTSTRAP=1 rustdoc -Zunstable-options --remap-path-prefix=./= ./x.rs

It reproduces with rustdoc, but not rustc.

We hit this building the documentation for the Linux kernel (for our custom compiler_builtins crate).

Meta

rustc 1.82.0 (f6e511eec 2024-10-15)
rustc 1.85.0 (4d91de4e4 2025-02-17)
rustc 1.86.0-beta.5 (b2af9a598 2025-03-08)
rustc 1.87.0-nightly (cbfdf0b01 2025-03-13)

It does not reproduce in 1.81.0, when the flag was introduced to rustdoc, but I imagine it is simply due to commit fd89197 ("Fix rustdoc missing handling of remap-path-prefix option").

Error output

internal error: entered unreachable code: attempted to remap an already remapped filename
Backtrace

thread 'rustc' panicked at compiler/rustc_span/src/source_map.rs:1170:34:
internal error: entered unreachable code: attempted to remap an already remapped filename
stack backtrace:
   0:     0x7d3d472dc07a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::he089f96442833f67
   1:     0x7d3d47a14d26 - core::fmt::write::h2f210ed4c94745cb
   2:     0x7d3d4890f7d1 - std::io::Write::write_fmt::h7de08171ab770fb2
   3:     0x7d3d472dbed2 - std::sys::backtrace::BacktraceLock::print::h810fbd31421329e6
   4:     0x7d3d472de477 - std::panicking::default_hook::{{closure}}::hbaad47ed9dc6356d
   5:     0x7d3d472de260 - std::panicking::default_hook::h24e207139139d40a
   6:     0x7d3d4644e258 - std[cba35227022cdb8c]::panicking::update_hook::<alloc[304106e3416ed1f2]::boxed::Box<rustc_driver_impl[16f35eaf1f029c02]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7d3d472decc3 - std::panicking::rust_panic_with_hook::ha9131beeb2ddc506
   8:     0x7d3d472de986 - std::panicking::begin_panic_handler::{{closure}}::h1bba0eaeb6da506f
   9:     0x7d3d472dc549 - std::sys::backtrace::__rust_end_short_backtrace::h1d1ca3eade483f4c
  10:     0x7d3d472de67d - rust_begin_unwind
  11:     0x7d3d43fa1480 - core::panicking::panic_fmt::h896a0727a1a943f9
  12:     0x7d3d48963cfb - <rustc_span[7c0f9ff7c6ad315d]::source_map::FilePathMapping>::map_filename_prefix
  13:     0x7d3d48963e37 - <rustc_span[7c0f9ff7c6ad315d]::source_map::SourceMap>::new_source_file
  14:     0x7d3d48963421 - rustc_parse[192da714918a5014]::new_parser_from_source_str
  15:     0x611ca64e52e6 - rustdoc[bc9829b44a9905a9]::clean::render_macro_matchers::render_macro_matcher
  16:     0x611ca64f6e7f - rustdoc[bc9829b44a9905a9]::clean::utils::render_macro_arms::<core[3b140760090fa97d]::iter::adapters::map::Map<core[3b140760090fa97d]::slice::iter::Chunks<rustc_ast[59cd571f1bf64f97]::tokenstream::TokenTree>, rustdoc[bc9829b44a9905a9]::clean::utils::display_macro_source::{closure#0}>>
  17:     0x611ca64f7069 - rustdoc[bc9829b44a9905a9]::clean::utils::display_macro_source
  18:     0x611ca650e915 - rustdoc[bc9829b44a9905a9]::clean::clean_maybe_renamed_item::{closure#1}
  19:     0x611ca64f81a5 - rustdoc[bc9829b44a9905a9]::clean::clean_doc_module
  20:     0x611ca6522159 - rustdoc[bc9829b44a9905a9]::core::run_global_ctxt
  21:     0x611ca63d5dde - rustc_interface[d49f06094f81b30c]::passes::create_and_enter_global_ctxt::<(), rustdoc[bc9829b44a9905a9]::main_args::{closure#2}::{closure#0}>::{closure#2}::{closure#0}
  22:     0x611ca63e3739 - <rustc_interface[d49f06094f81b30c]::passes::create_and_enter_global_ctxt<(), rustdoc[bc9829b44a9905a9]::main_args::{closure#2}::{closure#0}>::{closure#2} as core[3b140760090fa97d]::ops::function::FnOnce<(&rustc_session[8ddc36379c4b7790]::session::Session, rustc_middle[c26a501345a63c03]::ty::context::CurrentGcx, &std[cba35227022cdb8c]::sync::once_lock::OnceLock<rustc_middle[c26a501345a63c03]::ty::context::GlobalCtxt>, &rustc_data_structures[3109d5d84592bd45]::sync::worker_local::WorkerLocal<rustc_middle[c26a501345a63c03]::arena::Arena>, &rustc_data_structures[3109d5d84592bd45]::sync::worker_local::WorkerLocal<rustc_hir[22be481a0a9f7622]::Arena>, rustdoc[bc9829b44a9905a9]::main_args::{closure#2}::{closure#0})>>::call_once::{shim:vtable#0}
  23:     0x611ca63cf618 - rustc_interface[d49f06094f81b30c]::interface::run_compiler::<(), rustdoc[bc9829b44a9905a9]::main_args::{closure#2}>::{closure#1}
  24:     0x611ca6357f79 - std[cba35227022cdb8c]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[d49f06094f81b30c]::util::run_in_thread_with_globals<rustc_interface[d49f06094f81b30c]::util::run_in_thread_pool_with_globals<rustc_interface[d49f06094f81b30c]::interface::run_compiler<(), rustdoc[bc9829b44a9905a9]::main_args::{closure#2}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  25:     0x611ca63df67e - <<std[cba35227022cdb8c]::thread::Builder>::spawn_unchecked_<rustc_interface[d49f06094f81b30c]::util::run_in_thread_with_globals<rustc_interface[d49f06094f81b30c]::util::run_in_thread_pool_with_globals<rustc_interface[d49f06094f81b30c]::interface::run_compiler<(), rustdoc[bc9829b44a9905a9]::main_args::{closure#2}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[3b140760090fa97d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  26:     0x7d3d48835caf - std::sys::pal::unix::thread::Thread::new::thread_start::ha07e360225fa3528
  27:     0x7d3d42a9caa4 - <unknown>
  28:     0x7d3d42b29c3c - <unknown>
  29:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-rustdoc&template=ice.md

note: please make sure that you have updated to the latest nightly

note: please attach the file at `/t/rustc-ice-2025-03-14T20_33_42-48564.txt` to your bug report

note: compiler flags: -Z unstable-options

query stack during panic:
end of query stack

Cc: @GuillaumeGomez
@rustbot label A-rust-for-linux

@ojeda ojeda added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 14, 2025
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. A-rust-for-linux Relevant for the Rust-for-Linux project labels Mar 14, 2025
ojeda added a commit to ojeda/linux that referenced this issue Mar 14, 2025
`rustdoc` only recognizes `--remap-path-prefix` starting with
Rust 1.81.0, which is later than on minimum, so we cannot pass it
unconditionally. Otherwise, we get:

    error: Unrecognized option: 'remap-path-prefix'

Note that `rustc` (the compiler) does recognize the flag since a long
time ago (1.26.0).

Moreover, `rustdoc` since Rust 1.82.0 ICEs in out-of-tree builds when
using `--remap-path-prefix`. The issue has been reduced and reported
upstream [1].

Thus workaround both issues by simply skipping the flag when generating
the docs -- it is not critical there anyway.

Fixes: 6b5747d ("kbuild, rust: use -fremap-path-prefix to make paths relative")
Link: rust-lang/rust#138520 [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Mar 14, 2025
`rustdoc` only recognizes `--remap-path-prefix` starting with
Rust 1.81.0, which is later than on minimum, so we cannot pass it
unconditionally. Otherwise, we get:

    error: Unrecognized option: 'remap-path-prefix'

Note that `rustc` (the compiler) does recognize the flag since a long
time ago (1.26.0).

Moreover, `rustdoc` since Rust 1.82.0 ICEs in out-of-tree builds when
using `--remap-path-prefix`. The issue has been reduced and reported
upstream [1].

Thus workaround both issues by simply skipping the flag when generating
the docs -- it is not critical there anyway.

Fixes: 6b5747d ("kbuild, rust: use -fremap-path-prefix to make paths relative")
Link: rust-lang/rust#138520 [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
@fmease fmease added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-path-remapping Area: path remapping, --remap-path-prefix, --remap-cwd-prefix, --remap-diagnostics-scope etc. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 14, 2025
ojeda added a commit to ojeda/linux that referenced this issue Mar 15, 2025
`rustdoc` only recognizes `--remap-path-prefix` starting with
Rust 1.81.0, which is later than on minimum, so we cannot pass it
unconditionally. Otherwise, we get:

    error: Unrecognized option: 'remap-path-prefix'

Note that `rustc` (the compiler) does recognize the flag since a long
time ago (1.26.0).

Moreover, `rustdoc` since Rust 1.82.0 ICEs in out-of-tree builds when
using `--remap-path-prefix`. The issue has been reduced and reported
upstream [1].

Thus workaround both issues by simply skipping the flag when generating
the docs -- it is not critical there anyway.

Fixes: 6b5747d ("kbuild, rust: use -fremap-path-prefix to make paths relative")
Link: rust-lang/rust#138520 [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
ojeda added a commit to ojeda/linux that referenced this issue Mar 15, 2025
`rustdoc` only recognizes `--remap-path-prefix` starting with
Rust 1.81.0, which is later than on minimum, so we cannot pass it
unconditionally. Otherwise, we get:

    error: Unrecognized option: 'remap-path-prefix'

Note that `rustc` (the compiler) does recognize the flag since a long
time ago (1.26.0).

Moreover, `rustdoc` since Rust 1.82.0 ICEs in out-of-tree builds when
using `--remap-path-prefix`. The issue has been reduced and reported
upstream [1].

Thus workaround both issues by simply skipping the flag when generating
the docs -- it is not critical there anyway.

The ICE does not reproduce under `--test`, but we still need to skip
the flag as well for `RUSTDOC TK` since it is not recognized.

Fixes: 6b5747d ("kbuild, rust: use -fremap-path-prefix to make paths relative")
Link: rust-lang/rust#138520 [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Mar 15, 2025
`rustdoc` only recognizes `--remap-path-prefix` starting with
Rust 1.81.0, which is later than on minimum, so we cannot pass it
unconditionally. Otherwise, we get:

    error: Unrecognized option: 'remap-path-prefix'

Note that `rustc` (the compiler) does recognize the flag since a long
time ago (1.26.0).

Moreover, `rustdoc` since Rust 1.82.0 ICEs in out-of-tree builds when
using `--remap-path-prefix`. The issue has been reduced and reported
upstream [1].

Thus workaround both issues by simply skipping the flag when generating
the docs -- it is not critical there anyway.

The ICE does not reproduce under `--test`, but we still need to skip
the flag as well for `RUSTDOC TK` since it is not recognized.

Fixes: 6b5747d ("kbuild, rust: use -fremap-path-prefix to make paths relative")
Link: rust-lang/rust#138520 [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
charmitro added a commit to charmitro/rust that referenced this issue Mar 16, 2025
This commit fixes an internal compiler error (ICE) that occurs when
rustdoc attempts to remap a filename that was already remapped. The
issue arose during macro expansion when the `--remap-path-prefix`
option was used.

Instead of panicking with "attempted to remap an already remapped
filename", we now handle already remapped filenames gracefully by
returning them as-is.

A test case has been added to verify this behavior.

Fixes rust-lang#138520

Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
charmitro added a commit to charmitro/rust that referenced this issue Mar 16, 2025
This commit fixes an internal compiler error (ICE) that occurs when
rustdoc attempts to process macros with a remapped filename. The issue
arose during macro expansion when the `--remap-path-prefix` option was
used.

Instead of passing remapped filenames through, which would trigger the
"attempted to remap an already remapped filename" panic, we now
extract the original local path from remapped filenames before
processing them.

A test case has been added to verify this behavior.

Fixes rust-lang#138520

Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
charmitro added a commit to charmitro/rust that referenced this issue Mar 16, 2025
This commit fixes an internal compiler error (ICE) that occurs when
rustdoc attempts to process macros with a remapped filename. The issue
arose during macro expansion when the `--remap-path-prefix` option was
used.

Instead of passing remapped filenames through, which would trigger the
"attempted to remap an already remapped filename" panic, we now
extract the original local path from remapped filenames before
processing them.

A test case has been added to verify this behavior.

Fixes rust-lang#138520

Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
github-actions bot pushed a commit to anon503/linux that referenced this issue Mar 17, 2025
`rustdoc` only recognizes `--remap-path-prefix` starting with
Rust 1.81.0, which is later than on minimum, so we cannot pass it
unconditionally. Otherwise, we get:

    error: Unrecognized option: 'remap-path-prefix'

Note that `rustc` (the compiler) does recognize the flag since a long
time ago (1.26.0).

Moreover, `rustdoc` since Rust 1.82.0 ICEs in out-of-tree builds when
using `--remap-path-prefix`. The issue has been reduced and reported
upstream [1].

Thus workaround both issues by simply skipping the flag when generating
the docs -- it is not critical there anyway.

The ICE does not reproduce under `--test`, but we still need to skip
the flag as well for `RUSTDOC TK` since it is not recognized.

Fixes: dbdffaf ("kbuild, rust: use -fremap-path-prefix to make paths relative")
Link: rust-lang/rust#138520 [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Tamir Duberstein <tamird@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 17, 2025
…e, r=GuillaumeGomez,Urgau

Fix ICE: attempted to remap an already remapped filename

This commit fixes an internal compiler error (ICE) that occurs when
rustdoc attempts to process macros with a remapped filename. The issue
arose during macro expansion when the `--remap-path-prefix` option was
used.

Instead of passing remapped filenames through, which would trigger the
"attempted to remap an already remapped filename" panic, we now
extract the original local path from remapped filenames before
processing them.

A test case has been added to verify this behavior.

Fixes rust-lang#138520
jhpratt added a commit to jhpratt/rust that referenced this issue Mar 18, 2025
…e, r=GuillaumeGomez,Urgau

Fix ICE: attempted to remap an already remapped filename

This commit fixes an internal compiler error (ICE) that occurs when
rustdoc attempts to process macros with a remapped filename. The issue
arose during macro expansion when the `--remap-path-prefix` option was
used.

Instead of passing remapped filenames through, which would trigger the
"attempted to remap an already remapped filename" panic, we now
extract the original local path from remapped filenames before
processing them.

A test case has been added to verify this behavior.

Fixes rust-lang#138520
jhpratt added a commit to jhpratt/rust that referenced this issue Mar 18, 2025
…e, r=GuillaumeGomez,Urgau

Fix ICE: attempted to remap an already remapped filename

This commit fixes an internal compiler error (ICE) that occurs when
rustdoc attempts to process macros with a remapped filename. The issue
arose during macro expansion when the `--remap-path-prefix` option was
used.

Instead of passing remapped filenames through, which would trigger the
"attempted to remap an already remapped filename" panic, we now
extract the original local path from remapped filenames before
processing them.

A test case has been added to verify this behavior.

Fixes rust-lang#138520
@bors bors closed this as completed in b148106 Mar 18, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 18, 2025
Rollup merge of rust-lang#138556 - charmitro:already-remapped-filename, r=GuillaumeGomez,Urgau

Fix ICE: attempted to remap an already remapped filename

This commit fixes an internal compiler error (ICE) that occurs when
rustdoc attempts to process macros with a remapped filename. The issue
arose during macro expansion when the `--remap-path-prefix` option was
used.

Instead of passing remapped filenames through, which would trigger the
"attempted to remap an already remapped filename" panic, we now
extract the original local path from remapped filenames before
processing them.

A test case has been added to verify this behavior.

Fixes rust-lang#138520
github-actions bot pushed a commit to anon503/linux that referenced this issue Mar 19, 2025
`rustdoc` only recognizes `--remap-path-prefix` starting with
Rust 1.81.0, which is later than on minimum, so we cannot pass it
unconditionally. Otherwise, we get:

    error: Unrecognized option: 'remap-path-prefix'

Note that `rustc` (the compiler) does recognize the flag since a long
time ago (1.26.0).

Moreover, `rustdoc` since Rust 1.82.0 ICEs in out-of-tree builds when
using `--remap-path-prefix`. The issue has been reduced and reported
upstream [1].

Thus workaround both issues by simply skipping the flag when generating
the docs -- it is not critical there anyway.

The ICE does not reproduce under `--test`, but we still need to skip
the flag as well for `RUSTDOC TK` since it is not recognized.

Fixes: dbdffaf ("kbuild, rust: use -fremap-path-prefix to make paths relative")
Link: rust-lang/rust#138520 [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Tamir Duberstein <tamird@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-path-remapping Area: path remapping, --remap-path-prefix, --remap-cwd-prefix, --remap-diagnostics-scope etc. A-rust-for-linux Relevant for the Rust-for-Linux project C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants