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

Rustdoc ICE: Referencing a workspace crate's root in an intra-doc link triggers an ICE #84046

Closed
ThePuzzlemaker opened this issue Apr 10, 2021 · 5 comments · Fixed by #84066 or #84101
Closed
Assignees
Labels
A-resolve Area: Path resolution C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@ThePuzzlemaker
Copy link
Contributor

Code

The MCVE includes multiple crates so I've put it on a GitHub repo.

The command used for Rustdoc is just cargo +nightly doc.

Meta

rustc --version --verbose:

rustc 1.53.0-nightly (dae9d6ac3 2021-04-09)
binary: rustc
commit-hash: dae9d6ac3e9a8fb389cfe471b30f4d72c3122196
commit-date: 2021-04-09
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0

Error output

 Documenting rustdoc_ice_mcve v0.1.0 (/home/USER/Code/Rust/foo)
thread 'rustc' panicked at 'index out of bounds: the len is 18 but the index is 18', compiler/rustc_metadata/src/creader.rs:137:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

error: Unrecognized option: 'crate-version'

error: could not document `rustdoc_ice_mcve`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2018 --crate-type lib --crate-name rustdoc_ice_mcve src/lib.rs -o /home/USER/Code/Rust/foo/target/doc --error-format=json --json=diagnostic-rendered-ansi -L dependency=/home/USER/Code/Rust/foo/target/debug/deps --extern workspace_crate=/home/USER/Code/Rust/foo/target/debug/deps/libworkspace_crate-46c87e60a6b67395.rmeta --crate-version 0.1.0` (exit status: 1)
Backtrace

I've included the backtrace with `--verbose` as it mentioned `--crate-version`.

       Fresh workspace_crate v0.1.0 (/home/USER/Code/Rust/foo/workspace_crate)
 Documenting rustdoc_ice_mcve v0.1.0 (/home/USER/Code/Rust/foo)
     Running `rustdoc --edition=2018 --crate-type lib --crate-name rustdoc_ice_mcve src/lib.rs -o /home/USER/Code/Rust/foo/target/doc --error-format=json --json=diagnostic-rendered-ansi -L dependency=/home/USER/Code/Rust/foo/target/debug/deps --extern workspace_crate=/home/USER/Code/Rust/foo/target/debug/deps/libworkspace_crate-46c87e60a6b67395.rmeta --crate-version 0.1.0`
thread 'rustc' panicked at 'index out of bounds: the len is 18 but the index is 18', compiler/rustc_metadata/src/creader.rs:137:21
stack backtrace:
   0: rust_begin_unwind
             at /rustc/dae9d6ac3e9a8fb389cfe471b30f4d72c3122196/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/dae9d6ac3e9a8fb389cfe471b30f4d72c3122196/library/core/src/panicking.rs:92:14
   2: core::panicking::panic_bounds_check
             at /rustc/dae9d6ac3e9a8fb389cfe471b30f4d72c3122196/library/core/src/panicking.rs:69:5
   3: rustc_metadata::rmeta::decoder::cstore_impl::provide_extern::crate_name
   4: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
   5: rustc_data_structures::stack::ensure_sufficient_stack
   6: rustc_query_system::query::plumbing::force_query_with_job
   7: rustc_query_system::query::plumbing::get_query_impl
   8: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::crate_name
   9: rustdoc::clean::inline::record_extern_fqn
  10: rustdoc::clean::utils::register_res
  11: rustdoc::passes::collect_intra_doc_links::LinkCollector::resolve_link
  12: <rustdoc::passes::collect_intra_doc_links::LinkCollector as rustdoc::fold::DocFolder>::fold_item
  13: alloc::vec::source_iter_marker::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter
  14: rustdoc::fold::DocFolder::fold_inner_recur
  15: rustdoc::fold::DocFolder::fold_item_recur
  16: <rustdoc::passes::collect_intra_doc_links::LinkCollector as rustdoc::fold::DocFolder>::fold_item
  17: rustdoc::passes::collect_intra_doc_links::collect_intra_doc_links
  18: rustdoc::core::run_global_ctxt
  19: rustc_interface::passes::QueryContext::enter
  20: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  21: rustc_span::with_source_map
  22: rustc_interface::interface::create_compiler_and_run
  23: rustc_span::with_session_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

error: Unrecognized option: 'crate-version'

error: could not document `rustdoc_ice_mcve`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2018 --crate-type lib --crate-name rustdoc_ice_mcve src/lib.rs -o /home/USER/Code/Rust/foo/target/doc --error-format=json --json=diagnostic-rendered-ansi -L dependency=/home/USER/Code/Rust/foo/target/debug/deps --extern workspace_crate=/home/USER/Code/Rust/foo/target/debug/deps/libworkspace_crate-46c87e60a6b67395.rmeta --crate-version 0.1.0` (exit status: 1)

@ThePuzzlemaker ThePuzzlemaker 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 Apr 10, 2021
@jyn514
Copy link
Member

jyn514 commented Apr 10, 2021

Probably a regression from #83738. You said on discord this only happens on recent nightlies, right?

@jyn514 jyn514 added A-resolve Area: Path resolution T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 10, 2021
@jyn514
Copy link
Member

jyn514 commented Apr 10, 2021

cc #83761

@jyn514
Copy link
Member

jyn514 commented Apr 10, 2021

searched nightlies: from nightly-2021-04-03 to nightly-2021-04-09
regressed nightly: nightly-2021-04-04
searched commits: from 138fd56 to 0b417ab
regressed commit: 640ce99

bisected with cargo-bisect-rustc v0.6.0

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --preserve --start 2021-04-03 -- doc 

@jyn514 jyn514 added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Apr 10, 2021
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 10, 2021
@jyn514
Copy link
Member

jyn514 commented Apr 10, 2021

Rustdoc isn't stripping the backticks before loading the extern crates, this fixes the ICE:

/// Referencing a [workspace_crate] causes an ICE.

@jyn514 jyn514 added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Apr 10, 2021
@jyn514
Copy link
Member

jyn514 commented Apr 10, 2021

Mentoring instructions: Change this line to delete all ` in the link.

rust/src/librustdoc/core.rs

Lines 373 to 375 in 4029d4d

// FIXME: this misses a *lot* of the preprocessing done in collect_intra_doc_links
// I think most of it shouldn't be necessary since we only need the crate prefix?
let path_str = match Disambiguator::from_str(&link) {

@jyn514 jyn514 self-assigned this Apr 10, 2021
@bors bors closed this as completed in 1ff117e Apr 12, 2021
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Path resolution C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
4 participants