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 at IndexSet: index out of bounds #107353

Closed
RickkOne opened this issue Jan 27, 2023 · 10 comments · Fixed by #107931
Closed

ICE at IndexSet: index out of bounds #107353

RickkOne opened this issue Jan 27, 2023 · 10 comments · Fixed by #107931
Labels
C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue

Comments

@RickkOne
Copy link

RickkOne commented Jan 27, 2023

Not sure how helpful those notes are but I put them in here. Working on a web application using Sycamore.

thread 'rustc' panicked at 'IndexSet: index out of bounds', /rustc/0b90256ada21c6a81b4c18f2c7a23151ab5fc232\compiler\rustc_span\src\span_encoding.rs:171:43
stack backtrace:
   0:     0x7ffc5de59f52 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc866bf8b11919b4f
   1:     0x7ffc5de9668b - core::fmt::write::h67f5a998f81d6731
   2:     0x7ffc5de4cc8a - <std::io::IoSlice as core::fmt::Debug>::fmt::h2b24f2cd1b567825
   3:     0x7ffc5de59c9b - std::sys::common::alloc::realloc_fallback::h31973c0233ad2da2
   4:     0x7ffc5de5d649 - std::panicking::default_hook::hce60451ac7b3ab94
   5:     0x7ffc5de5d2cb - std::panicking::default_hook::hce60451ac7b3ab94
   6:     0x7ffc4f27c37f - rustc_driver[bb081788fe83386c]::describe_lints
   7:     0x7ffc5de5dfaf - std::panicking::rust_panic_with_hook::h698ff0019e4f0cfb
   8:     0x7ffc5de5dd0e - <std::panicking::begin_panic_handler::StrPanicPayload as core::panic::BoxMeUp>::get::h736b7927b09a1075
   9:     0x7ffc5de5ac4f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc866bf8b11919b4f
  10:     0x7ffc5de5d9c0 - rust_begin_unwind
  11:     0x7ffc5decc215 - core::panicking::panic_fmt::hce3f805b550bd1ec
  12:     0x7ffc5de93440 - <core::panic::panic_info::PanicInfo as core::fmt::Display>::fmt::hf81485f6a8a4e354
  13:     0x7ffc5de933eb - <core::panic::panic_info::PanicInfo as core::fmt::Display>::fmt::hf81485f6a8a4e354
  14:     0x7ffc5decc1d9 - core::option::expect_failed::h42ce0e15bfaf5156
  15:     0x7ffc4ca7fbdd - <rustc_resolve[b7e0286c7682748f]::Resolver>::resolve_crate
  16:     0x7ffc4e12c677 - <rustc_resolve[b7e0286c7682748f]::build_reduced_graph::BuildReducedGraphVisitor as rustc_ast[407d373202de5639]::visit::Visitor>::visit_ty
  17:     0x7ffc4e17ac87 - <rustc_resolve[b7e0286c7682748f]::Resolver>::legacy_const_generic_args
  18:     0x7ffc4e14ecef - <rustc_resolve[b7e0286c7682748f]::Resolver as rustc_expand[cfd628860559efaf]::base::ResolverExpand>::resolve_macro_invocation
  19:     0x7ffc4d61000e - <rustc_expand[cfd628860559efaf]::expand::MacroExpander>::fully_expand_fragment
  20:     0x7ffc4c47a9f9 - <rustc_expand[cfd628860559efaf]::expand::MacroExpander>::expand_crate
  21:     0x7ffc4d907eab - rustc_infer[37c14617e2f47f45]::infer::outlives::explicit_outlives_bounds
  22:     0x7ffc4c5dde90 - rustc_interface[4c4a2b2ce0ade12b]::passes::configure_and_expand
  23:     0x7ffc4c5c4556 - <rustc_interface[4c4a2b2ce0ade12b]::queries::Queries>::expansion
  24:     0x7ffc4c3dc89c - rustc_driver[bb081788fe83386c]::args::arg_expand_all
  25:     0x7ffc4c3c0d22 - <rustc_data_structures[2a4e4975c8d1ae43]::temp_dir::MaybeTempDir>::new
  26:     0x7ffc4c3dbe16 - rustc_driver[bb081788fe83386c]::args::arg_expand_all
  27:     0x7ffc4c3cc123 - <rustc_data_structures[2a4e4975c8d1ae43]::temp_dir::MaybeTempDir>::new
  28:     0x7ffc4c3c4b2d - <rustc_data_structures[2a4e4975c8d1ae43]::temp_dir::MaybeTempDir>::new
  29:     0x7ffc5de70b3c - std::sys::windows::thread::Thread::new::hd0260019de9c231a
  30:     0x7ffce6fd7614 - BaseThreadInitThunk
  31:     0x7ffce79026a1 - RtlUserThreadStart

error: internal compiler error: unexpected panic

note: 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-compiler&template=ice.md

note: rustc 1.68.0-nightly (0b90256ad 2023-01-13) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `frontend`
2023-01-27T10:28:03.504827Z ERROR  error
error from HTML pipeline
@workingjubilee workingjubilee added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ C-bug Category: This is a bug. labels Jan 27, 2023
@workingjubilee
Copy link
Member

What's the code that induced this compiler panic?

@Rageking8
Copy link
Contributor

@rustbot label +E-needs-mcve

@rustbot rustbot added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Jan 27, 2023
@Noratrieb Noratrieb changed the title Compiler unexpectedly panicked ICE at IndexSet: index out of bounds Jan 27, 2023
@fpoli
Copy link
Contributor

fpoli commented Feb 8, 2023

This happened to me with rustc 1.68.0-nightly (afaf3e07a 2023-01-14) running on x86_64-unknown-linux-gnu. Removing a whitespace at the end of a line made the compiler panic.

I attach a minimized workspace to reproduce the crash. What's funny is that there is a file (spaghetti_module.rs) where deleting even just one character makes the crash disappear.

ice-crate.zip

@workingjubilee workingjubilee added the S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue label Feb 10, 2023
@workingjubilee
Copy link
Member

workingjubilee commented Feb 10, 2023

Given that this automated(?) reduction is still a big workspace, I'm actually going to leave the E-needs-mcve here because my hunch is this is still probably further minimizable, but thank you! Entirely possible I'm wrong, and this should be reduced enough to go by.

@jieyouxu
Copy link
Member

jieyouxu commented Feb 11, 2023

A slightly smaller ICE reproducer: https://github.com/jieyouxu/issue-107353-reproducer. Note it doesn't compile because I trimmed out all the definitions prior to main, but still ICEs.

rustc 1.69.0-nightly (2773383a3 2023-02-10)
binary: rustc
commit-hash: 2773383a314a4b8f481ce2bed12c32de794ffbe9
commit-date: 2023-02-10
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7

@jieyouxu

This comment was marked as outdated.

@jieyouxu
Copy link
Member

jieyouxu commented Feb 11, 2023

I think I found the issue: it has to do with SpanData interning. Specifically, if you manage to fit a function of the following signature to somewhere around MAX_LEN == i16::MAX == 32767 (defined in rustc_span::span_encoding) it will trigger some kind of edge case in span data interning and cause the index to be confused with base (or for some other cause that lead to this).

Minimal reproducer is just

fn a() -> &'a T {
/ 32763 times
}

and longer lifetime names will also trigger ICE.

@jieyouxu

This comment was marked as resolved.

@jieyouxu
Copy link
Member

searched nightlies: from nightly-2022-01-01 to nightly-2023-02-10
regressed nightly: nightly-2023-01-03
searched commit range: 7742995...d6f99e5
regressed commit: fb9dfa8

bisected with cargo-bisect-rustc v0.6.5

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

cargo bisect-rustc --preserve --start=2022-01-01 --end=2023-02-10

@cjgillot
Copy link
Contributor

The bug is that MAX_LEN | PARENT_MASK == LEN_TAG. The "inline format with parent" should check than len_or_tag != LEN_TAG.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants