Skip to content

Index out of bounds when running cargo doc in rustc_metadata/src/creader.rs #84738

Description

@XAMPPRocky

EDIT(camelid): This issue is now being used to track a different, but related, bug. The discussion starting here is current.

Steps

  • Clone rust-gpu.
  • cargo doc -p spirv-std --no-deps

Meta

rustc --version --verbose:

rustc 1.53.0-nightly (42816d61e 2021-04-24)
binary: rustc
commit-hash: 42816d61ead7e46d462df997958ccfd514f8c21c
commit-date: 2021-04-24
host: x86_64-apple-darwin
release: 1.53.0-nightly
LLVM version: 12.0.0

Error output

thread 'rustc' panicked at 'index out of bounds: the len is 8 but the index is 8', 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 `spirv-std`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2018 --crate-type lib --crate-name spirv_std crates/spirv-std/src/lib.rs -o /Users/erin.power/src/rust-gpu2/target/doc --cfg 'feature="default"' --error-format=json --json=diagnostic-rendered-ansi -L dependency=/Users/erin.power/src/rust-gpu2/target/debug/deps --extern bitflags=/Users/erin.power/src/rust-gpu2/target/debug/deps/libbitflags-7c13a8e06c86cae3.rmeta --extern num_traits=/Users/erin.power/src/rust-gpu2/target/debug/deps/libnum_traits-226168b7b64579d8.rmeta --extern spirv_std_macros=/Users/erin.power/src/rust-gpu2/target/debug/deps/libspirv_std_macros-63f1f4de237cb2bc.dylib --extern spirv_types=/Users/erin.power/src/rust-gpu2/target/debug/deps/libspirv_types-7559b6c8fd9bbf59.rmeta --crate-version 0.4.0-alpha.7` (exit status: 1)
Backtrace

   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   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: rustdoc::main_options
  24: scoped_tls::ScopedKey<T>::set

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Apr 30, 2021
  2. jyn514 commented on Apr 30, 2021

    @jyn514
    Member

    @XAMPPRocky this is probably related to #83761 somehow. I don't plan to investigate any of the proximate issues until the underlying problem is fixed. Feel free to take a look yourself if this is blocking your work, but it won't be easy.

  3. added
    A-resolveArea: Name/path resolution done by `rustc_resolve` specifically
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    and removed
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Apr 30, 2021
  4. jyn514 commented on Apr 30, 2021

    @jyn514
    Member

    Oh, I guess this could also be a missed case from #83738. That should be easier to fix.

  5. jyn514 commented on Apr 30, 2021

    @jyn514
    Member

    If you can come up with an MCVE it would be easier to tell which of the two issues it is.

  6. added
    E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
    on Apr 30, 2021
  7. mautamu commented on May 3, 2021

    @mautamu
    Contributor

    Not exactly an MCVE, but I think I'm able to reproduce this with only a handful of files @jyn514. The line
    thread 'rustc' panicked at 'index out of bounds: the len is 8 but the index is 8', compiler/rustc_metadata/src/creader.rs:137:21
    does change slightly though:
    thread 'rustc' panicked at 'index out of bounds: the len is 20 but the index is 20', compiler/rustc_metadata/src/creader.rs:137:21

    https://github.com/mautamu/spirv-std-3

    (Same rustc version output as above).

    Hope this helps :).

    Best,
    Mautamu

  8. jyn514 commented on May 3, 2021

    @jyn514
    Member

    DEBUG rustdoc::passes::collect_intra_doc_links combined_docs=[ImageFormat]: spirv_types::image_params::ImageFormat
    DEBUG rustdoc::passes::collect_intra_doc_links resolving spirv_types::image_params::ImageFormat as a macro in the module DefId(19:0 ~ spirv_std_macros[a0e2])

    I think the issue is that the crate is first used in a dependency, so it isn't loaded in

    if let Some(doc) = attr.doc_str() {
    for link in markdown_links(&doc.as_str()) {

    Maybe a fix is to recursively traverse the docs of re-exports? That sounds kind of expensive, but the only other option (besides fixing #83761) is to revert and re-open #68427.

  9. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on May 3, 2021
  10. jyn514 commented on May 3, 2021

    @jyn514
    Member

    An easy workaround is to link to spirv_types somewhere in the crate re-exporting the docs, even something like this would work:

    diff --git a/src/lib.rs b/src/lib.rs
    index d4de24e..81c278f 100644
    --- a/src/lib.rs
    +++ b/src/lib.rs
    @@ -1 +1,5 @@
     pub use spirv_std_macros::Image;
    +
    +#[doc(hidden)]
    +/// [spirv_types]
    +pub fn workaround_rustdoc_ice_84738() {}
  11. 40 remaining items

  12. added
    P-highHigh priority
    and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    P-highHigh priority
    on Nov 2, 2021
  13. jyn514 commented on Nov 7, 2021

    @jyn514
    Member
  14. jyn514 commented on Nov 8, 2021

    @jyn514
    Member
  15. added a commit that references this issue on Nov 11, 2021
  16. added a commit that references this issue on Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-criticalCritical priorityT-rustdocRelevant to the rustdoc 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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions