Skip to content
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

ICE on "index out of bounds: the len is 3 but the index is 4" #62895

Closed
dwrensha opened this issue Jul 23, 2019 · 0 comments · Fixed by #62887
Closed

ICE on "index out of bounds: the len is 3 but the index is 4" #62895

dwrensha opened this issue Jul 23, 2019 · 0 comments · Fixed by #62887
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dwrensha
Copy link
Contributor

I'm getting an internal compiler error on the following program (found by fuzz-rustc):

// run-pass

fn v() -> isize {
    mod  _{
        pub fn g() -> isizee {
mod  _{
        pub    g() -> is
   (), w20);
  }

   (), w20);
}
$ RUST_BACKTRACE=1 rustc main.rs
error: expected identifier, found reserved identifier `_`
 --> main.rs:4:10
  |
4 |     mod  _{
  |          ^ expected identifier, found reserved identifier

error: expected identifier, found reserved identifier `_`
 --> main.rs:6:6
  |
6 | mod  _{
  |      ^ expected identifier, found reserved identifier

thread 'rustc' panicked at 'index out of bounds: the len is 3 but the index is 4', /rustc/273f42b5964c29dda2c5a349dd4655529767b07f/src/libcore/slice/mod.rs:2687:14
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.heygears.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.heygears.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:47
   3: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:36
   4: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:200
   5: std::panicking::default_hook
             at src/libstd/panicking.rs:214
   6: rustc::util::common::panic_hook
   7: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:481
   8: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:384
   9: rust_begin_unwind
             at src/libstd/panicking.rs:311
  10: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
  11: core::panicking::panic_bounds_check
             at src/libcore/panicking.rs:61
  12: syntax::parse::parser::Parser::parse_item_
  13: syntax::parse::parser::Parser::parse_item
  14: syntax::parse::parser::Parser::parse_mod_items
  15: syntax::parse::parser::Parser::parse_item_implementation
  16: syntax::parse::parser::Parser::parse_item_
  17: syntax::parse::parser::Parser::parse_stmt_without_recovery
  18: syntax::parse::parser::Parser::parse_full_stmt
  19: syntax::parse::parser::Parser::parse_block_tail
  20: syntax::parse::parser::Parser::parse_inner_attrs_and_block
  21: syntax::parse::parser::Parser::parse_item_fn
  22: syntax::parse::parser::Parser::parse_item_implementation
  23: syntax::parse::parser::Parser::parse_item_
  24: syntax::parse::parser::Parser::parse_item
  25: syntax::parse::parser::Parser::parse_mod_items
  26: syntax::parse::parser::Parser::parse_item_implementation
  27: syntax::parse::parser::Parser::parse_item_
  28: syntax::parse::parser::Parser::parse_stmt_without_recovery
  29: syntax::parse::parser::Parser::parse_full_stmt
  30: syntax::parse::parser::Parser::parse_block_tail
  31: syntax::parse::parser::Parser::parse_inner_attrs_and_block
  32: syntax::parse::parser::Parser::parse_item_fn
  33: syntax::parse::parser::Parser::parse_item_implementation
  34: syntax::parse::parser::Parser::parse_item_
  35: syntax::parse::parser::Parser::parse_item
  36: syntax::parse::parser::Parser::parse_mod_items
  37: syntax::parse::parser::Parser::parse_crate_mod
  38: syntax::parse::parse_crate_from_file
  39: rustc_interface::passes::parse::{{closure}}
  40: rustc::util::common::time
  41: rustc_interface::passes::parse
  42: rustc_interface::queries::Query<T>::compute
  43: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::parse
  44: rustc_interface::interface::run_compiler_in_existing_thread_pool
  45: std::thread::local::LocalKey<T>::with
  46: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
end of query stack
error: aborting due to 2 previous errors


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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.38.0-nightly (273f42b59 2019-07-21) running on x86_64-unknown-linux-gnu

I'm seeing the error on stable, beta, and nightly. As with #62881, the error occurs on nightly-2018-12-14 (f4a421e) but not on nightly-2018-12-08 (4a45578).

#62887, the proposed fix for #62881, does not fix this error. cc @estebank

@jonas-schievink jonas-schievink added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-nominated regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. and removed regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels Jul 23, 2019
@estebank estebank self-assigned this Jul 23, 2019
@nikomatsakis nikomatsakis added P-high High priority and removed I-nominated labels Jul 25, 2019
Centril added a commit to Centril/rust that referenced this issue Jul 25, 2019
Make the parser TokenStream more resilient after mismatched delimiter recovery

Fix rust-lang#62881, fix rust-lang#62895.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants