Uh oh!
There was an error while loading. Please reload this page.
Fix find_width_of_character_at_span bounds check - #48522
Conversation
Commit 0bd9667 added bounds checking of our current target byte position to prevent infinite loops. Unfortunately it was comparing the file-relative `target` versus the global relative `file_start_pos` and `file_end_pos`. The result is failing to detect multibyte characters unless their file-relative offset fit within their global offset. This causes other parts of the compiler to generate spans pointing to the middle of a multibyte character which will ultimately panic in `bytepos_to_file_charpos`. Fix by comparing the `target` to the total file size when moving forward and doing checked subtraction when moving backwards. This should preserve the intent of the bounds check while removing the offset confusion. Fixes#48508
rust-highfive
commented
Feb 25, 2018
(rust_highfive has picked a reviewer for you, use r? to override) |
estebank
commented
Feb 26, 2018
Could you add a test to catch any regressions? |
This is named for the issue as it's testing the specific details of that bug. It's a bit tricky as the ICE requires multiple files and debug info enabled to trigger.
etaoins
commented
Feb 26, 2018
@estebank Added a new commit with a test |
estebank
commented
Feb 26, 2018
@bors r+ |
bors
commented
Feb 26, 2018
📌 Commit c237d4f has been approved by |
nikomatsakis
commented
Feb 27, 2018
r? @estebank |
Manishearth
commented
Feb 28, 2018
Fails pretty: |
etaoins
commented
Feb 28, 2018
@Manishearth That looks like a bug in pretty, no? The test compiles and runs correctly so I'm not sure why pretty can't typecheck it. Is it worth committing this without the test? cc @estebank |
| @@ -0,0 +1,16 @@ | |||
| // Copyright 2018 The Rust Project Developers. See the COPYRIGHT | |||
There was a problem hiding this comment.
Shouldn't this file be in the auxiliary folder?
There was a problem hiding this comment.
Everything in auxillary is treated as a crate. This needs to be a module to trigger #48508
Manishearth
commented
Feb 28, 2018
Perhaps. The |
The out-of-line module #37195
etaoins
commented
Mar 1, 2018
Looks like this was triggering #37195. Pushed an |
Manishearth
commented
Mar 1, 2018
@bors r=estebank |
bors
commented
Mar 1, 2018
📌 Commit 363d604 has been approved by |
…-at-span-bounds-check, r=estebank Fix find_width_of_character_at_span bounds check Commit 0bd9667 added bounds checking of our current target byte position to prevent infinite loops. Unfortunately it was comparing the file-relative `target` versus the global `file_start_pos` and `file_end_pos`. The result is failing to detect multibyte characters unless their file-relative offset fit within their global offset. This causes other parts of the compiler to generate spans pointing to the middle of a multibyte character which will ultimately panic in `bytepos_to_file_charpos`. Fix by comparing the `target` to the total file size when moving forward and doing checked subtraction when moving backwards. This should preserve the intent of the bounds check while removing the offset confusion. cc @davidtwcoFixesrust-lang#48508
Commit 0bd9667 added bounds checking of our current target byte position to prevent infinite loops. Unfortunately it was comparing the file-relative
targetversus the globalfile_start_posandfile_end_pos.The result is failing to detect multibyte characters unless their file-relative offset fit within their global offset. This causes other parts of the compiler to generate spans pointing to the middle of a
multibyte character which will ultimately panic in
bytepos_to_file_charpos.Fix by comparing the
targetto the total file size when moving forward and doing checked subtraction when moving backwards. This should preserve the intent of the bounds check while removing the offset confusion.cc @davidtwco
Fixes#48508