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

ICE: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32 #127823

Closed
matthiaskrgr opened this issue Jul 16, 2024 · 4 comments · Fixed by #127835
Closed

ICE: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32 #127823

matthiaskrgr opened this issue Jul 16, 2024 · 4 comments · Fixed by #127835
Labels
A-parser Area: The parsing of Rust source code to an AST A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` 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) ❄️ P-medium Medium priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

snippet:

const A: usize2; 

Version information

rustc 1.81.0-nightly (a91f7d72f 2024-07-16)
binary: rustc
commit-hash: a91f7d72f12efcc00ecf71591f066c534d45ddf7
commit-date: 2024-07-16
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: unknown start of token: \u{2a75}
 --> /tmp/icemaker_global_tempdir.e46gMaSgxB9W/rustc_testrunner_tmpdir_reporting.ZkkxHf7ZZ25i/mvce.rs:1:16
  |
1 | const A: usize ⩵ 2; 
  |                ^
  |
help: Unicode character '⩵' (Two Consecutive Equals Signs) looks like '==' (Double Equals Sign), but it is not
  |
1 | const A: usize == 2; 
  |                ~~

error: unexpected `==`
 --> /tmp/icemaker_global_tempdir.e46gMaSgxB9W/rustc_testrunner_tmpdir_reporting.ZkkxHf7ZZ25i/mvce.rs:1:16
  |
1 | const A: usize ⩵ 2; 
  |                ^
  |
thread 'rustc' panicked at compiler/rustc_span/src/lib.rs:2097:17:
assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32
stack backtrace:
   0:     0x7c1cc09de3e5 - std::backtrace_rs::backtrace::libunwind::trace::hf161671508d91847
                               at /rustc/a91f7d72f12efcc00ecf71591f066c534d45ddf7/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7c1cc09de3e5 - std::backtrace_rs::backtrace::trace_unsynchronized::ha0d0b669fae1a811
                               at /rustc/a91f7d72f12efcc00ecf71591f066c534d45ddf7/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7c1cc09de3e5 - std::sys::backtrace::_print_fmt::h0aca386296ab9399
                               at /rustc/a91f7d72f12efcc00ecf71591f066c534d45ddf7/library/std/src/sys/backtrace.rs:65:5
   3:     0x7c1cc09de3e5 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hcd42b85197cbd4bf
                               at /rustc/a91f7d72f12efcc00ecf71591f066c534d45ddf7/library/std/src/sys/backtrace.rs:40:26
   4:     0x7c1cc0a2de1b - core::fmt::rt::Argument::fmt::hf236502f93c8e5ff
                               at /rustc/a91f7d72f12efcc00ecf71591f066c534d45ddf7/library/core/src/fmt/rt.rs:173:76
   5:     0x7c1cc0a2de1b - core::fmt::write::h9402866ea48d1483
                               at /rustc/a91f7d72f12efcc00ecf71591f066c534d45ddf7/library/core/src/fmt/mod.rs:1182:21
   6:     0x7c1cc09d2e9f - std::io::Write::write_fmt::h2c3d8e1efe7ea8ed
                               at /rustc/a91f7d72f12efcc00ecf71591f066c534d45ddf7/library/std/src/io/mod.rs:1827:15
   7:     0x7c1cc09e0bd1 - std::sys::backtrace::BacktraceLock::print::h0ad6c09d6cb14f3a
                               at /rustc/a91f7d72f12efcc00ecf71591f066c534d45ddf7/library/std/src/sys/backtrace.rs:43:9
   8:     0x7c1cc09e0bd1 - std::panicking::default_hook::{{closure}}::ha6830a71dd04e1d3
                               at /rustc/a91f7d72f12efcc00ecf71591f066c534d45ddf7/library/std/src/panicking.rs:269:22
   9:     0x7c1cc09e08ac - std::panicking::default_hook::hb2a8d12f4d199973
                               at /rustc/a91f7d72f12efcc00ecf71591f066c534d45ddf7/library/std/src/panicking.rs:296:9
  10:     0x7c1cbcde6eb9 - std[1bed36f9a066cc23]::panicking::update_hook::<alloc[1b688835cd2a2549]::boxed::Box<rustc_driver_impl[e130c54fc211eddf]::install_ice_hook::{closure#0}>>::{closure#0}
  11:     0x7c1cc09e159f - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hc820f5fd79138be0
                               at /rustc/a91f7d72f12efcc00ecf71591f066c534d45ddf7/library/alloc/src/boxed.rs:2084:9
  12:     0x7c1cc09e159f - std::panicking::rust_panic_with_hook::h53eadb333b03e88a
                               at /rustc/a91f7d72f12efcc00ecf71591f066c534d45ddf7/library/std/src/panicking.rs:808:13
  13:     0x7c1cc09e1193 - std::panicking::begin_panic_handler::{{closure}}::h00b6e00c8a1e50fb
                               at /rustc/a91f7d72f12efcc00ecf71591f066c534d45ddf7/library/std/src/panicking.rs:667:13
  14:     0x7c1cc09de8a9 - std::sys::backtrace::__rust_end_short_backtrace::h1b6119584a4140da
                               at /rustc/a91f7d72f12efcc00ecf71591f066c534d45ddf7/library/std/src/sys/backtrace.rs:168:18
  15:     0x7c1cc09e0e54 - rust_begin_unwind
                               at /rustc/a91f7d72f12efcc00ecf71591f066c534d45ddf7/library/std/src/panicking.rs:665:5
  16:     0x7c1cc0a2a3d3 - core::panicking::panic_fmt::h358ee3e3c9634fac
                               at /rustc/a91f7d72f12efcc00ecf71591f066c534d45ddf7/library/core/src/panicking.rs:74:14
  17:     0x7c1cc0a2a45c - core::panicking::panic::h3ae669dd273e0024
                               at /rustc/a91f7d72f12efcc00ecf71591f066c534d45ddf7/library/core/src/panicking.rs:148:5
  18:     0x7c1cbefd66e0 - <rustc_span[52a25f9bbeabff3d]::source_map::SourceMap>::lookup_char_pos
  19:     0x7c1cbf35d312 - <rustc_span[52a25f9bbeabff3d]::source_map::SourceMap>::is_valid_span
  20:     0x7c1cbf35b1a7 - <core[8f9ded7ca307af34]::iter::adapters::filter_map::FilterMap<core[8f9ded7ca307af34]::iter::adapters::cloned::Cloned<core[8f9ded7ca307af34]::iter::adapters::filter::Filter<core[8f9ded7ca307af34]::slice::iter::Iter<rustc_errors[f6c64b3ee2e0fa3b]::Substitution>, <rustc_errors[f6c64b3ee2e0fa3b]::CodeSuggestion>::splice_lines::{closure#0}>>, <rustc_errors[f6c64b3ee2e0fa3b]::CodeSuggestion>::splice_lines::{closure#1}> as core[8f9ded7ca307af34]::iter::traits::iterator::Iterator>::next
  21:     0x7c1cbf09891c - <rustc_errors[f6c64b3ee2e0fa3b]::emitter::HumanEmitter>::emit_messages_default
  22:     0x7c1cbf573fcf - <rustc_errors[f6c64b3ee2e0fa3b]::emitter::HumanEmitter as rustc_errors[f6c64b3ee2e0fa3b]::emitter::Emitter>::emit_diagnostic
  23:     0x7c1cbf572e89 - <rustc_errors[f6c64b3ee2e0fa3b]::DiagCtxtInner>::emit_diagnostic::{closure#3}
  24:     0x7c1cbf5716bc - rustc_interface[c56d2d1714ec79e6]::callbacks::track_diagnostic::<core[8f9ded7ca307af34]::option::Option<rustc_span[52a25f9bbeabff3d]::ErrorGuaranteed>>
  25:     0x7c1cbf56fcbb - <rustc_errors[f6c64b3ee2e0fa3b]::DiagCtxtInner>::emit_diagnostic
  26:     0x7c1cbf56fb61 - <rustc_errors[f6c64b3ee2e0fa3b]::DiagCtxtHandle>::emit_diagnostic
  27:     0x7c1cbf56ed15 - <rustc_span[52a25f9bbeabff3d]::ErrorGuaranteed as rustc_errors[f6c64b3ee2e0fa3b]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  28:     0x7c1cbf43ebab - <rustc_interface[c56d2d1714ec79e6]::queries::Queries>::parse
  29:     0x7c1cbf1c9946 - rustc_interface[c56d2d1714ec79e6]::interface::run_compiler::<core[8f9ded7ca307af34]::result::Result<(), rustc_span[52a25f9bbeabff3d]::ErrorGuaranteed>, rustc_driver_impl[e130c54fc211eddf]::run_compiler::{closure#0}>::{closure#1}
  30:     0x7c1cbf19edc9 - std[1bed36f9a066cc23]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[c56d2d1714ec79e6]::util::run_in_thread_with_globals<rustc_interface[c56d2d1714ec79e6]::util::run_in_thread_pool_with_globals<rustc_interface[c56d2d1714ec79e6]::interface::run_compiler<core[8f9ded7ca307af34]::result::Result<(), rustc_span[52a25f9bbeabff3d]::ErrorGuaranteed>, rustc_driver_impl[e130c54fc211eddf]::run_compiler::{closure#0}>::{closure#1}, core[8f9ded7ca307af34]::result::Result<(), rustc_span[52a25f9bbeabff3d]::ErrorGuaranteed>>::{closure#0}, core[8f9ded7ca307af34]::result::Result<(), rustc_span[52a25f9bbeabff3d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8f9ded7ca307af34]::result::Result<(), rustc_span[52a25f9bbeabff3d]::ErrorGuaranteed>>
  31:     0x7c1cbf19eb7a - <<std[1bed36f9a066cc23]::thread::Builder>::spawn_unchecked_<rustc_interface[c56d2d1714ec79e6]::util::run_in_thread_with_globals<rustc_interface[c56d2d1714ec79e6]::util::run_in_thread_pool_with_globals<rustc_interface[c56d2d1714ec79e6]::interface::run_compiler<core[8f9ded7ca307af34]::result::Result<(), rustc_span[52a25f9bbeabff3d]::ErrorGuaranteed>, rustc_driver_impl[e130c54fc211eddf]::run_compiler::{closure#0}>::{closure#1}, core[8f9ded7ca307af34]::result::Result<(), rustc_span[52a25f9bbeabff3d]::ErrorGuaranteed>>::{closure#0}, core[8f9ded7ca307af34]::result::Result<(), rustc_span[52a25f9bbeabff3d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8f9ded7ca307af34]::result::Result<(), rustc_span[52a25f9bbeabff3d]::ErrorGuaranteed>>::{closure#2} as core[8f9ded7ca307af34]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:     0x7c1cc09eb5fb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hcc85614f472ca83b
                               at /rustc/a91f7d72f12efcc00ecf71591f066c534d45ddf7/library/alloc/src/boxed.rs:2070:9
  33:     0x7c1cc09eb5fb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb0e377a5e4dea4a7
                               at /rustc/a91f7d72f12efcc00ecf71591f066c534d45ddf7/library/alloc/src/boxed.rs:2070:9
  34:     0x7c1cc09eb5fb - std::sys::pal::unix::thread::Thread::new::thread_start::h31c873416e697604
                               at /rustc/a91f7d72f12efcc00ecf71591f066c534d45ddf7/library/std/src/sys/pal/unix/thread.rs:108:17
  35:     0x7c1cc077fded - <unknown>
  36:     0x7c1cc08030dc - <unknown>
  37:                0x0 - <unknown>

error: 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: please make sure that you have updated to the latest nightly

note: rustc 1.81.0-nightly (a91f7d72f 2024-07-16) running on x86_64-unknown-linux-gnu

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


@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Jul 16, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 16, 2024
@matthiaskrgr
Copy link
Member Author

#127407 cc @estebank

@estebank
Copy link
Contributor

I suspect that we don't really need multibyte_chars anymore, tbh.

@estebank
Copy link
Contributor

Addressed in #127835. Every time I convince myself that "synthesizing a Span is ok this time", I'm proved wrong.

@estebank estebank added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Jul 16, 2024
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jul 16, 2024
@estebank estebank added A-parser Area: The parsing of Rust source code to an AST A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jul 16, 2024
@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added the P-medium Medium priority label Jul 17, 2024
@bors bors closed this as completed in 50a90e3 Jul 19, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jul 19, 2024
Rollup merge of rust-lang#127835 - estebank:issue-127823, r=compiler-errors

Fix ICE in suggestion caused by `⩵` being recovered as `==`

The second suggestion shown here would previously incorrectly assume that the span corresponding to `⩵` was 2 bytes wide composed by 2 1 byte wide chars, so a span pointing at `==` could point only at one of the `=` to remove it. Instead, we now replace the whole thing (as we should have the whole time):

```
error: unknown start of token: \u{2a75}
  --> $DIR/unicode-double-equals-recovery.rs:1:16
   |
LL | const A: usize ⩵ 2;
   |                ^
   |
help: Unicode character '⩵' (Two Consecutive Equals Signs) looks like '==' (Double Equals Sign), but it is not
   |
LL | const A: usize == 2;
   |                ~~

error: unexpected `==`
  --> $DIR/unicode-double-equals-recovery.rs:1:16
   |
LL | const A: usize ⩵ 2;
   |                ^
   |
help: try using `=` instead
   |
LL | const A: usize = 2;
   |                ~
```

Fix rust-lang#127823.
@jieyouxu jieyouxu added the D-Unicode-unaware Diagnostics: Diagnostics that are unaware of Unicode and trigger codepoint boundary assertions label Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: The parsing of Rust source code to an AST A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` 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) ❄️ P-medium Medium priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. 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.

5 participants