-
Notifications
You must be signed in to change notification settings - Fork 13.3k
ICE: IndexSet: index out of bounds', /rustc/8460ca823e8367a30dda430efda790588b8c84d3/compiler/rustc_span/src/span_encoding.rs #110230
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
I noticed there is an older bug that is probably the same: #100715. |
So like I said this ICE is extremely sensitive to the exact number of characters and lines. The contents of those lines seems to matter less; it is possible to replace most comment and identifier characters with another character (I tried 'x') as long as the total number of characters stays the same. Likewise, a tab can be replaced with a space. The code that triggers is the last code line in this function (from https://github.com/rust-lang/rust/blob/1.68.1/compiler/rustc_span/src/span_encoding.rs): /// Internal function to translate between an encoded span and the expanded representation.
/// This function must not be used outside the incremental engine.
#[inline]
pub fn data_untracked(self) -> SpanData {
if self.len_or_tag != LEN_TAG {
// Inline format.
if self.len_or_tag & PARENT_MASK == 0 {
debug_assert!(self.len_or_tag as u32 <= MAX_LEN);
SpanData {
lo: BytePos(self.base_or_index),
hi: BytePos(self.base_or_index + self.len_or_tag as u32),
ctxt: SyntaxContext::from_u32(self.ctxt_or_tag as u32),
parent: None,
}
} else {
let len = self.len_or_tag & !PARENT_MASK;
debug_assert!(len as u32 <= MAX_LEN);
let parent =
LocalDefId { local_def_index: DefIndex::from_u32(self.ctxt_or_tag as u32) };
SpanData {
lo: BytePos(self.base_or_index),
hi: BytePos(self.base_or_index + len as u32),
ctxt: SyntaxContext::root(),
parent: Some(parent),
}
}
} else {
// Interned format.
let index = self.base_or_index;
with_span_interner(|interner| interner.spans[index as usize]) // *** THIS LINE ***
}
} with_span_interner calls a function on the SpanInterner it gets from with_session_globals which gets it from thread-local-storage // If an interner exists, return it. Otherwise, prepare a fresh one.
#[inline]
fn with_span_interner<T, F: FnOnce(&mut SpanInterner) -> T>(f: F) -> T {
crate::with_session_globals(|session_globals| f(&mut session_globals.span_interner.lock()))
} A SpanInterner wraps a FxIndexSet of SpanData: #[derive(Default)]
pub struct SpanInterner {
spans: FxIndexSet<SpanData>,
} which is just an indexmap::IndexSet with the FxHasher (https://github.com/rust-lang/rust/blob/1.68.1/compiler/rustc_data_structures/src/fx.rs#L8) pub type FxIndexSet<V> = indexmap::IndexSet<V, BuildHasherDefault<FxHasher>>; The indexmap version is "1.9.2" (https://github.com/rust-lang/rust/blob/1.68.1/Cargo.lock#L2156)
The latest version is 1.9.3, but it does not seem to contain any relevant changes (indexmap-rs/indexmap@1.9.2...1.9.3). indexmap uses hashbrown for its hashtable, which may mean that this bug ultimately comes from hashbrown. |
A bug in hashbrown is very unlikely. Do you have a backtrace with symbol names? |
@cjgillot Are you able to reproduce the issue given my test case? Can you explain what goes wrong? |
Refactor `SyntaxContext::ctxt` logic. I'm still trying to make a test from the issue. cc `@deepink-mas` does this solve the issue? Fixes rust-lang#110230
Refactor `SyntaxContext::ctxt` logic. I'm still trying to make a test from the issue. cc ``@deepink-mas`` does this solve the issue? Fixes rust-lang#110230
Refactor `SyntaxContext::ctxt` logic. I'm still trying to make a test from the issue. cc ```@deepink-mas``` does this solve the issue? Fixes rust-lang#110230
Refactor `SyntaxContext::ctxt` logic. I'm still trying to make a test from the issue. cc `@deepink-mas` does this solve the issue? Fixes rust-lang/rust#110230
Refactor `SyntaxContext::ctxt` logic. I'm still trying to make a test from the issue. cc `@deepink-mas` does this solve the issue? Fixes rust-lang/rust#110230
Refactor `SyntaxContext::ctxt` logic. I'm still trying to make a test from the issue. cc `@deepink-mas` does this solve the issue? Fixes rust-lang/rust#110230
Put the following code in a new crate's src/main.rs and call 'cargo init'. Then 'cargo c' will ICE. I've tried to reduce further but it seems like if I remove any random line (even if it is a comment) the ICE goes away.
Code
Meta
rustc --version --verbose
:Error output
Backtrace
The text was updated successfully, but these errors were encountered: