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

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

Closed
dwrensha opened this issue Dec 31, 2021 · 4 comments · Fixed by #100226
Closed

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

dwrensha opened this issue Dec 31, 2021 · 4 comments · Fixed by #100226
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. D-Unicode-unaware Diagnostics: Diagnostics that are unaware of Unicode and trigger codepoint boundary assertions 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.

Comments

@dwrensha
Copy link
Contributor

$ echo -n 'fn f(){(print!(á' > bug.rs
$ rustc bug.rs
error: this file contains an unclosed delimiter
 --> bug.rs:1:17
  |
1 | fn f(){(print!(á
  |       --      - ^
  |       ||      |
  |       ||      unclosed delimiter
  |       |unclosed delimiter
  |       unclosed delimiter

error: format argument must be a string literal
 --> bug.rs:1:16
  |
1 | fn f(){(print!(á
  |                ^
  |
help: you might be missing a string literal to format with
  |
1 | fn f(){(print!("{}", á
  |                +++++

thread 'rustc' panicked at 'assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32', compiler/rustc_span/src/lib.rs:1710:17
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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.59.0-nightly (83b15bfe1 2021-12-28) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to 2 previous errors

Reported by @Badel2 here: #92267 (comment)
(Note that #92460 fixes #92267, but does not fix this bug.)

@dwrensha dwrensha added C-bug Category: This is a bug. 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 Dec 31, 2021
@dwrensha
Copy link
Contributor Author

searched nightlies: from nightly-2021-01-07 to nightly-2021-12-24
regressed nightly: nightly-2021-09-12
searched commits: from b69fe57 to 8c2b6ea
regressed commit: 43769af

bisected with cargo-bisect-rustc v0.6.0

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start=2021-1-7 --end=2021-12-24 --regress ice 

@dwrensha
Copy link
Contributor Author

This regression was introduced in #88779. cc @estebank

@dwrensha
Copy link
Contributor Author

Not a fix, but if I make this change

diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs
index 755e24d5413..a74a83567a3 100644
--- a/compiler/rustc_lint/src/unused.rs
+++ b/compiler/rustc_lint/src/unused.rs
@@ -512,7 +512,7 @@ fn emit_unused_delims_expr(
                 if value.span.from_expansion() || expr.span.from_expansion() {
                     (
                         value.span.with_hi(value.span.lo() + BytePos(1)),
-                        value.span.with_lo(value.span.hi() - BytePos(1)),
+                        value.span.with_lo(value.span.hi()),
                     )
                 } else {
                     (value.span.with_hi(expr.span.lo()), value.span.with_lo(expr.span.hi()))

then there is no longer an ICE and I get

error: this file contains an unclosed delimiter
 --> /home/dwrensha/Desktop/bug.rs:1:17
  |
1 | fn f(){(print!(á
  |       --      - ^
  |       ||      |
  |       ||      unclosed delimiter
  |       |unclosed delimiter
  |       unclosed delimiter

error: format argument must be a string literal
 --> /home/dwrensha/Desktop/bug.rs:1:16
  |
1 | fn f(){(print!(á
  |                ^
  |
help: you might be missing a string literal to format with
  |
1 | fn f(){(print!("{}", á
  |                +++++

warning: unnecessary parentheses around block return value
 --> /home/dwrensha/Desktop/bug.rs:1:8
  |
1 | fn f(){(print!(á
  |        ^        ^
  |
  = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
  |
1 - fn f(){(print!(á
1 + fn f(){print!(á
  | 

error: aborting due to 2 previous errors; 1 warning emitted

@Badel2
Copy link
Contributor

Badel2 commented Jan 1, 2022

Thanks for opening the issue @dwrensha.

If someone finds a fix but doesn't know how to add the test, this pull request which solves a similar ICE has an example of how to add a test when there is a missing newline:

#91273

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Aug 9, 2022
Do not manually craft a span pointing inside a multibyte character.

Fixes rust-lang#92462
@bors bors closed this as completed in e6c9594 Aug 10, 2022
@jieyouxu jieyouxu added A-diagnostics Area: Messages for errors, warnings, and lints D-Unicode-unaware Diagnostics: Diagnostics that are unaware of Unicode and trigger codepoint boundary assertions labels Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. D-Unicode-unaware Diagnostics: Diagnostics that are unaware of Unicode and trigger codepoint boundary assertions 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants