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 on "internal error: entered unreachable code" #63116

Closed
dwrensha opened this issue Jul 29, 2019 · 4 comments · Fixed by #66471
Closed

ICE on "internal error: entered unreachable code" #63116

dwrensha opened this issue Jul 29, 2019 · 4 comments · Fixed by #66471
Labels
A-parser Area: The parsing of Rust source code to an AST. C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dwrensha
Copy link
Contributor

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

impl W <s(f;Y(;]
error: this file contains an un-closed delimiter
 --> main.rs:1:18
  |
1 | impl W <s(f;Y(;]
  |          -       ^
  |          |
  |          un-closed delimiter

error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `;`
 --> main.rs:1:12
  |
1 | impl W <s(f;Y(;]
  |            ^ expected one of 7 possible tokens here

error: expected one of `!`, `&&`, `&`, `(`, `)`, `*`, `+`, `,`, `->`, `...`, `::`, `<`, `>`, `?`, `[`, `_`, `dyn`, `extern`, `fn`, `for`, `impl`, `unsafe`, or lifetime, found `;`
 --> main.rs:1:15
  |
1 | impl W <s(f;Y(;]
  |              -^ help: `)` may belong here
  |              |
  |              unclosed delimiter

thread 'rustc' panicked at 'internal error: entered unreachable code', src/libsyntax/parse/parser.rs:565:22
stack backtrace:
   0: std::panicking::default_hook::{{closure}}
   1: std::panicking::default_hook
   2: rustc::util::common::panic_hook
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic
   5: syntax::parse::parser::Parser::expect_gt
   6: syntax::parse::parser::Parser::parse_path_segment
   7: syntax::parse::parser::Parser::parse_path_segments
   8: syntax::parse::parser::Parser::parse_path
   9: syntax::parse::parser::Parser::parse_ty_common
  10: syntax::parse::parser::Parser::parse_item_implementation
  11: syntax::parse::parser::Parser::parse_item_
  12: syntax::parse::parser::Parser::parse_item
  13: syntax::parse::parser::Parser::parse_mod_items
  14: syntax::parse::parser::Parser::parse_crate_mod
  15: syntax::parse::parse_crate_from_file
  16: rustc_interface::passes::parse::{{closure}}
  17: rustc::util::common::time
  18: rustc_interface::passes::parse
  19: rustc_interface::queries::Query<T>::compute
  20: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::parse
  21: rustc_interface::interface::run_compiler_in_existing_thread_pool
  22: std::thread::local::LocalKey<T>::with
  23: scoped_tls::ScopedKey<T>::set
  24: 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 3 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 (4560cb830 2019-07-28) running on x86_64-apple-darwin

This error does not occur on stable or beta, nor on a nightly from last week.

@jonas-schievink jonas-schievink added A-parser Area: The parsing of Rust source code to an AST. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 29, 2019
@dwrensha
Copy link
Contributor Author

dwrensha commented Jul 30, 2019

The panic is being thrown from here:

Ok(_) => unreachable!(),

That code assumes that self.expect_one_of(&[], &[]) will always return Err(_). However, in this case expect_one_of() calls expected_one_of_not_found(), which returns Ok(_) from here:

return Ok(recovered);

@dwrensha
Copy link
Contributor Author

cc @estebank

@JohnTitor
Copy link
Member

JohnTitor commented Nov 16, 2019

Seems fixed in the latest nightly(playground), marked as E-needstest

@JohnTitor JohnTitor added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Nov 16, 2019
@Alexendoo
Copy link
Member

I'll add a test for this

Centril added a commit to Centril/rust that referenced this issue Nov 17, 2019
@bors bors closed this as completed in 750dd03 Nov 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: The parsing of Rust source code to an AST. C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ 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.

5 participants