Skip to content

thread 'rustc' panicked at 'begin <= end (2 <= 1) when slicing r"' #70677

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

Closed
dwrensha opened this issue Apr 1, 2020 · 3 comments · Fixed by #70681
Closed

thread 'rustc' panicked at 'begin <= end (2 <= 1) when slicing r"' #70677

dwrensha opened this issue Apr 1, 2020 · 3 comments · Fixed by #70681
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The lexing & parsing of Rust source code to an AST I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dwrensha
Copy link
Contributor

dwrensha commented Apr 1, 2020

On a recent commit (235938d, not yet on a nightly release), I'm seeing the following internal compiler error (found by fuzz-rustc):

$ echo -n 'r"' > main.rs
$ build/x86_64-unknown-linux-gnu/stage1/bin/rustc main.rs
thread 'rustc' panicked at 'begin <= end (2 <= 1) when slicing `r"`', /home/dwrensha/src/rust/src/libcore/str/mod.rs:1920:47
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.44.0-dev running on x86_64-unknown-linux-gnu
@dwrensha
Copy link
Contributor Author

dwrensha commented Apr 1, 2020

I'm guessing that #70522 is to blame. cc @rcoh

@rcoh
Copy link
Contributor

rcoh commented Apr 2, 2020

yeah probably me. will fix.
Here is the relevant section of stack trace:

             at src/libcore/panicking.rs:111
  15: core::str::slice_error_fail
             at src/libcore/str/mod.rs:0
  16: core::str::traits::<impl core::slice::SliceIndex<str> for core::ops::range::Range<usize>>::index::{{closure}}
             at ./src/libcore/str/mod.rs:1920
  17: rustc_parse::lexer::StringReader::cook_lexer_token
             at src/librustc_parse/lexer/mod.rs:0
  18: rustc_parse::lexer::StringReader::next_token
             at src/librustc_parse/lexer/mod.rs:133
  19: rustc_parse::lexer::tokentrees::TokenTreesReader::real_token
             at src/librustc_parse/lexer/tokentrees.rs:248
  20: rustc_parse::lexer::tokentrees::TokenTreesReader::parse_all_token_trees
             at src/librustc_parse/lexer/tokentrees.rs:52
  21: rustc_parse::lexer::tokentrees::<impl rustc_parse::lexer::StringReader>::into_token_trees
             at src/librustc_parse/lexer/tokentrees.rs:26
  22: rustc_parse::maybe_file_to_stream
             at src/librustc_parse/lib.rs:202
  23: rustc_parse::maybe_source_file_to_parser
             at src/librustc_parse/lib.rs:137
  24: rustc_parse::source_file_to_parser
             at src/librustc_parse/lib.rs:127
  25: rustc_parse::new_parser_from_file
             at src/librustc_parse/lib.rs:112

@dwrensha
Copy link
Contributor Author

dwrensha commented Apr 2, 2020

cargo-bisect-rustc confirms that 235938d is where this error first showed up.

Also, the latest nightly is now out and it the error happens on it.

Centril added a commit to Centril/rust that referenced this issue Apr 2, 2020
…=petrochenkov

Handle unterminated raw strings with no #s properly

The modified code to handle parsing raw strings didn't properly account for the case where there was no "#" on either end and erroneously reported this strings as complete. This lead to a panic trying to read off the end of the file.

Fixes rust-lang#70677

r? @petrochenkov

cc @Centril
@Centril Centril added 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 Apr 2, 2020
@Centril Centril added A-parser Area: The lexing & parsing of Rust source code to an AST P-high High priority A-diagnostics Area: Messages for errors, warnings, and lints labels Apr 2, 2020
@bors bors closed this as completed in ec0da72 Apr 2, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The lexing & parsing of Rust source code to an AST I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority 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.

3 participants