-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
thread 'rustc' panicked at 'begin <= end (2 <= 0) when slicing #71471
Comments
Will do a quick investigation and find out |
Backtrace :
The error probably originates from: rust/src/librustc_parse/lexer/mod.rs Line 98 in 235938d
|
@rustbot claim |
Assigning |
Should we add the need-bisection label? |
this also looks suspicious: https://github.com/rust-lang/rust/pull/71372/files |
OK, I've determined the root cause. https://github.com/rust-lang/rust/pull/71372/files changes the shebang handling to strip whitespace -- the intention was to strip internal whitespace to fix #70528 , but it's also stripping external whitespace which (I believe) is a bug. |
Revert rust-lang#71372 ("Fix #! (shebang) stripping account space issue"). While rust-lang#71372 fixed some of the problems `#!`-stripping had, it introduced others: * inefficient implementation (`.chars().filter(...).collect()` on the entire input file) * this also means the length returned isn't always correct, leading to e.g. rust-lang#71471 * it ignores whitespace anywhere, stripping ` # ! ...` which isn't a valid shebang * the definition of "whitespace" it uses includes newlines, which means even `\n#\n!\n...` is stripped as a shebang (and anything matching the regex `\s*#\s*!\s*`, and not followed by `[`, really) * it's backward-incompatible but didn't go through Crater Now, rust-lang#71487 is already open and will solve all of these issues. But for running Crater, and just in case rust-lang#71487 takes a bit longer, I decided it's safer to just revert rust-lang#71372. This will also make rust-lang#71372's diff clearer, as it will start again from the original whitespace-unaware version. r? @petrochenkov
It looks like this was fixed by #71634, so I think it can be closed. |
Shebang handling was too agressive in stripping out the first line in cases where it is actually _not_ a shebang, but instead, valid rust (rust-lang#70528). This is a second attempt at resolving this issue (the first attempt was flawed, for, among other reasons, causing an ICE in certain cases (rust-lang#71372, rust-lang#71471). The behavior is now codified by a number of UI tests, but simply: For the first line to be a shebang, the following must all be true: 1. The line must start with `#!` 2. The line must contain a non whitespace character after `#!` 3. The next character in the file, ignoring comments & whitespace must not be `[` I believe this is a strict superset of what we used to allow, so perhaps a crater run is unnecessary, but probably not a terrible idea.
Fix bug in shebang handling Shebang handling was too agressive in stripping out the first line in cases where it is actually _not_ a shebang, but instead, valid rust (rust-lang#70528). This is a second attempt at resolving this issue (the first attempt was reverted, for, among other reasons, causing an ICE in certain cases (rust-lang#71372, rust-lang#71471). The behavior is now codified by a number of UI tests, but simply: For the first line to be a shebang, the following must all be true: 1. The line must start with `#!` 2. The line must contain a non-whitespace character after `#!` 3. The next character in the file, ignoring comments & whitespace must not be `[` I believe this is a strict superset of what we used to allow, so perhaps a crater run is unnecessary, but probably not a terrible idea. Fixes rust-lang#70528
I'm seeing an internal compiler error on the input "\n#!B\n" (found by fuzz-rustc):
This issue has been assigned to @rcoh via this comment.
The text was updated successfully, but these errors were encountered: