Repository navigation
compiler panic: "byte index 10 is not a char boundary" #62524
Copy link
Copy link
Labels
A-UnicodeArea: UnicodeArea: UnicodeA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Description
$ rustc -Vv
rustc 1.36.0 (a53f9df32 2019-07-03)
binary: rustc
commit-hash: a53f9df32fbb0b5f4382caaad8f1a46f36ea887c
commit-date: 2019-07-03
host: x86_64-apple-darwin
release: 1.36.0
LLVM version: 8.0
$ echo Zm4gbWFpbigo2Lw= | base64 -D > main.rs
$ rustc main.rs
error: this file contains an un-closed delimiter
--> main.rs:1:11
|
1 | fn main((ؼ
| -- ^
| ||
| |un-closed delimiter
| un-closed delimiter
thread 'rustc' panicked at 'byte index 10 is not a char boundary; it is inside 'ؼ' (bytes 9..11) of `fn main((ؼ`', src/libcore/str/mod.rs:2034:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: aborting due to previous error
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.36.0 (a53f9df32 2019-07-03) running on x86_64-apple-darwin
Found with the help of libfuzzer-sys.
Metadata
Metadata
Assignees
Labels
A-UnicodeArea: UnicodeArea: UnicodeA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Activity
ExpHP commentedon Jul 9, 2019
There's two slicing operations in
find_width_of_character_at_span. I'm trying to figure out how a non-boundary index could be appearing in there... maybeunexpected_try_recoveris callingnext_pointwith a span that begins at index 10? (where does this come from?Parser.prev_span?) Building a debug compiler to check those log statements...Edit: Building the debug compiler was a bust. Embarassingly, things seem to have changed and I don't know how to get those debug macros to fire in the current compiler.
pnkfelix commentedon Jul 11, 2019
@ExpHP do you mean you were using
RUST_LOGand not seeing debug output?If so, that is because the environment variable name under
rustcwas changed toRUSTC_LOG. (I make this mistake pretty much every day due to muscle memory.)As an example, here is the tail of my log output:
pnkfelix commentedon Jul 11, 2019
triage: P-medium. Removing nomination.
pnkfelix commentedon Jul 11, 2019
This was broken between 1.15 and 1.16, but those are so old and the nature of the ICE itself has changed from 1.28 to 1.29, so I do not think bisection would be worthwhile.
ExpHP commentedon Jul 11, 2019
Offtopic
@pnkfelix : Thanks. Unfortunately, I did guess the name of
RUSTC_LOGafterRUST_LOGdidn't work, and all it showed me was this:I set
debug = truein myconfig.tomlbefore building, and didn't see anything else in there. (I recall thatdebug!andtrace!used to be explicitly mentioned in the comment fordebug-assertionsbut it is no longer, so I did not enable it.)ExpHP commentedon Jul 11, 2019
Okay, I did the following evil, evil thing:
Pure evil, do not open
And acquired the following backtrace of when the span was first constructed:
It also gets constructed a second time:
Second backtrace
(the region of the backtrace that differs between the two is items 22-29 in the first one, or 22-25 in the second)
Some interesting spots from here:
This is clearly where the value of 10 is created:
rust/src/libsyntax/tokenstream.rs
Lines 136 to 144 in 4bb6b4a
TokenCursor::nextcalls this if there are no remaining tokens and it still hasn't seen the closing delimiter (it seems to have as an unstated precondition that the closing delimiter must exist).Here's the innermost bit that's specific to
identparsing. Doesn't look that odd...rust/src/libsyntax/parse/parser.rs
Lines 622 to 634 in 4bb6b4a
pnkfelix commentedon Jul 11, 2019
@ExpHP I’m not familiar with
RUSTC_LOG=traceI tend to list (comma separated) module paths in my own use of RUSTC_LOG; did you try that? You can see an example in the transcript I gave in my comment above
5 remaining items
Rollup merge of rust-lang#66054 - petrochenkov:delspan, r=estebank
Rollup merge of rust-lang#66054 - petrochenkov:delspan, r=estebank
JohnTitor commentedon Nov 13, 2019
Hm, the example from #62524 (comment) hasn't been fixed?
Alexendoo commentedon Nov 13, 2019
Seems so, on the current nightly:
guanqun commentedon Nov 13, 2019
@Alexendoo I guess my fix #66264 would help. I'll get some time to test it out.
guanqun commentedon Nov 15, 2019
Confirmed that my fix fixed this issue, I also add this unit test in this PR: #66429
add a unit test for rust-lang#62524
Rollup merge of rust-lang#66429 - guanqun:add-unit-test, r=Centril
Rollup merge of rust-lang#66429 - guanqun:add-unit-test, r=Centril
Auto merge of #66449 - tmandry:rollup-3p1t0sb, r=tmandry