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

Use next_point to avoid ICE #68735

Merged
merged 1 commit into from
Feb 3, 2020
Merged

Use next_point to avoid ICE #68735

merged 1 commit into from
Feb 3, 2020

Conversation

JohnTitor
Copy link
Member

Fixes #68730

r? @estebank (I think you're familiar with that)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 1, 2020
@@ -671,12 +671,12 @@ impl<'a> Parser<'a> {
true
}
token::BinOp(token::Shl) => {
let span = self.token.span.with_lo(self.token.span.lo() + BytePos(1));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a bunch of other instances of self.token.span.lo() + BytePos(1) in this file. Should they be updated too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine to do so if @estebank also agrees with that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhm, I found out it shouldn't, it'll break many spans.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What kind of breakage occurs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed we can use next_ponit for eat_plus but it seems to cause breakage in other places (expect_and, expect_or, and expect_gt). It will expand or reduce current span size.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we should also tweak later bump_withs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you file a ticket to follow up on this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed as #68783.

@estebank
Copy link
Contributor

estebank commented Feb 2, 2020

I'm +1 r=me on the change as is, but if we can avoid the other + BytePos(1) usages throughout we'll get ahead of any potential lurking ICEs.

@estebank
Copy link
Contributor

estebank commented Feb 2, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Feb 2, 2020

📌 Commit 6f5a61b has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 2, 2020
bors added a commit that referenced this pull request Feb 3, 2020
Use `next_point` to avoid ICE

Fixes #68730

r? @estebank (I think you're familiar with that)
@bors
Copy link
Contributor

bors commented Feb 3, 2020

⌛ Testing commit 6f5a61b with merge 01db581...

@bors
Copy link
Contributor

bors commented Feb 3, 2020

☀️ Test successful - checks-azure
Approved by: estebank
Pushing 01db581 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 3, 2020
@bors bors merged commit 6f5a61b into rust-lang:master Feb 3, 2020
@JohnTitor JohnTitor deleted the fix-ice-0202 branch February 3, 2020 05:27
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Feb 6, 2020
stop using BytePos for computing spans in librustc_parse/parser/mod.rs

Computing spans using logic such as `self.token.span.lo() + BytePos(1)` can cause internal compiler errors like rust-lang#68730 when non-ascii characters are given as input.

rust-lang#68735 partially addressed this problem, but only for one case. Moreover, its usage of `next_point()` does not actually align with what `bump_with()` expects. For example, given the token `>>=`, we should pass the span consisting of the final two characters `>=`, but `next_point()` advances the span beyond the end of the `=`.

This pull request instead computes the start of the new span by doing `start_point(self.token.span).hi()`. This matches `self.token.span.lo() + BytePos(1)` in the common case where the characters are ascii, and it gracefully handles multibyte characters.

Fixes rust-lang#68783.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32
5 participants