-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Index out of bounds when running cargo doc
in rustc_metadata/src/creader.rs
#84738
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
@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. |
Oh, I guess this could also be a missed case from #83738. That should be easier to fix. |
If you can come up with an MCVE it would be easier to tell which of the two issues it is. |
Not exactly an MCVE, but I think I'm able to reproduce this with only a handful of files @jyn514. The line https://github.com/mautamu/spirv-std-3 (Same rustc version output as above). Hope this helps :). Best, |
I think the issue is that the crate is first used in a dependency, so it isn't loaded in rust/src/librustdoc/passes/collect_intra_doc_links/early.rs Lines 30 to 31 in e327a82
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. |
An easy workaround is to link to 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() {} |
Hmm, this setup didn't reproduce the issue, not sure why:
|
Maybe the proc macro is related somehow? |
Regression in 640ce99 searched nightlies: from nightly-2021-01-01 to nightly-2021-04-24 bisected with cargo-bisect-rustc v0.6.0Host triple: x86_64-unknown-linux-gnu cargo bisect-rustc --test-dir=. --start=2021-01-01 --script=./script.sh |
This regression now slipped into beta 1.53.0. |
@Aaron1011 came up with a slightly smaller reproduction, the proc macro wasn't related: https://github.com/Aaron1011/spirv-std-3/tree/no-macro |
We've also run into this recently with a rather trivial crate https://docs.rs/crate/lightning-background-processor/0.0.98 |
#90283 reports the same issue in an open source codebase: penumbra-zone/penumbra@1bf5d1b |
Also seeing this in another project in 1.56 stable. Would put together a reproducer but there already is one. |
@drewcrawford If you could minimize the crash that would be helpful, the one at the top was already fixed by #88215 |
I've reduced it to https://github.com/drewcrawford/rustc-84738. Still seems a bit large but having trouble getting it any smaller. This reproducer involves rust-lang/cargo#6313. I suspect that is the root cause in this case, not sure if that tracks with the other reports. |
@drewcrawford how can I build that package? running
even though I have gcc installed. |
The dependency is macOS only. GitHub runners can do it. There is probably a way to shrink the dependency enough to build on some other platform, can look into it a bit more |
@jyn514 Updated to ICE on windows, which I suspect is enough for linux as well. May require |
Hmm, so something strange is going on here - I minimized @drewcrawford's example a little more, down to four local crates:
If |
@drewcrawford FWIW you can work around the ICE with this diff: diff --git a/src/objcinstance.rs b/src/objcinstance.rs
index f876cd5..1264f19 100644
--- a/src/objcinstance.rs
+++ b/src/objcinstance.rs
@@ -126,7 +126,7 @@ pub trait ObjcInstanceBehavior {
///Safely casts the object to an `Option<NonNullImmutable>`. Suitable for implementing nullable functions.
fn nullable(ptr: *const Self) -> Option<NonNullImmutable<Self>>;
- ///Allows you to call [objr::bindings::PerformsSelector::perform] from a nonmutating context.
+ ///Allows you to call [crate::bindings::PerformsSelector::perform] from a nonmutating context.
///
/// This function should not be used for general-purpose pointer casting.
/// |
Really interesting workaround! Those ought to be the same due to #56409, maybe there’s some interaction there? |
@drewcrawford see #83761 |
This helps with (but does not fix) rust-lang#84738. I tested on jyn514/objr@edcee7b and still hit ICEs.
MCVE: #90489 (comment) |
…trochenkov rustdoc: Go back to loading all external crates unconditionally This *continues* to cause regressions. This code will be unnecessary once access to the resolver happens fully before creating the tyctxt (rust-lang#83761), so load all crates unconditionally for now. To minimize churn, this leaves in the code for loading crates selectively. "Fixes" rust-lang#84738. Previously: rust-lang#83738, rust-lang#85749, rust-lang#88215 r? `@petrochenkov` cc `@camelid` (this should fix the "index out of bounds" error you had while looking up `crate_name`).
…ochenkov rustdoc: Go back to loading all external crates unconditionally This *continues* to cause regressions. This code will be unnecessary once access to the resolver happens fully before creating the tyctxt (rust-lang#83761), so load all crates unconditionally for now. To minimize churn, this leaves in the code for loading crates selectively. "Fixes" rust-lang#84738. Previously: rust-lang#83738, rust-lang#85749, rust-lang#88215 r? `@petrochenkov` cc `@camelid` (this should fix the "index out of bounds" error you had while looking up `crate_name`).
This helps with (but does not fix) rust-lang#84738. I tested on jyn514/objr@edcee7b and still hit ICEs. (cherry picked from commit cdafe99)
EDIT(camelid): This issue is now being used to track a different, but related, bug. The discussion starting here is current.
Steps
rust-gpu
.cargo doc -p spirv-std --no-deps
Meta
rustc --version --verbose
:Error output
Backtrace
The text was updated successfully, but these errors were encountered: