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

Greek question mark causes ICE #123607

Closed
Alcaro opened this issue Apr 7, 2024 · 2 comments · Fixed by #123609
Closed

Greek question mark causes ICE #123607

Alcaro opened this issue Apr 7, 2024 · 2 comments · Fixed by #123609
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints 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) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Alcaro
Copy link
Contributor

Alcaro commented Apr 7, 2024

https://godbolt.org/z/Yd76o7Ybq
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9cf4205afdba1abc79336f966f95f6ff

Code

pub fn square(num: i32) -> i32 {
    num * num;
}

Note: that's a greek question mark, not a semicolon

Meta

rustc --version --verbose:

rustc 1.77.0 (aedd173a2 2024-03-17)
binary: rustc
commit-hash: aedd173a2c086e558c2b66d3743b344f977621a7
commit-date: 2024-03-17
host: x86_64-unknown-linux-gnu
release: 1.77.0
LLVM version: 17.0.6
Compiler returned: 0

Error output

error: unknown start of token: \u{37e}
 --> <source>:2:14
  |
2 |     num * num;
  |              ^
  |
help: Unicode character ';' (Greek Question Mark) looks like ';' (Semicolon), but it is not
  |
2 |     num * num;
  |              ~

thread 'rustc' panicked at compiler/rustc_span/src/lib.rs:2019:17:
assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32
stack backtrace:
   0:     0x7fb2cd416d16 - std::backtrace_rs::backtrace::libunwind::trace::h92ba5ac126ecc5ad
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
Rest of the output
   1:     0x7fb2cd416d16 - std::backtrace_rs::backtrace::trace_unsynchronized::hfaa118b6e3a8f31a
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fb2cd416d16 - std::sys_common::backtrace::_print_fmt::h2075f185adf13bbd
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fb2cd416d16 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9c4bd387f9f3f544
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fb2cd469770 - core::fmt::rt::Argument::fmt::h018ecebdf268b5bb
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/core/src/fmt/rt.rs:142:9
   5:     0x7fb2cd469770 - core::fmt::write::h938c332fdab924eb
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/core/src/fmt/mod.rs:1120:17
   6:     0x7fb2cd40a58f - std::io::Write::write_fmt::h4a694b02e44e6363
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/io/mod.rs:1846:15
   7:     0x7fb2cd416af4 - std::sys_common::backtrace::_print::h3595c0f4303f3ccd
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fb2cd416af4 - std::sys_common::backtrace::print::ha888e6736b0bc71f
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fb2cd419887 - std::panicking::default_hook::{{closure}}::he19a7f79f7beab5e
  10:     0x7fb2cd4195e9 - std::panicking::default_hook::h67efe04e9a5d446e
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/panicking.rs:292:9
  11:     0x7fb2ca3af6bc - std[c78d3cd131ec7074]::panicking::update_hook::<alloc[4e128ca7a2328977]::boxed::Box<rustc_driver_impl[f73d4ac0dd51449f]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7fb2cd419fd6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h9c9759b104a0af15
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/alloc/src/boxed.rs:2029:9
  13:     0x7fb2cd419fd6 - std::panicking::rust_panic_with_hook::h49021cdbc4b22349
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/panicking.rs:785:13
  14:     0x7fb2cd419ce9 - std::panicking::begin_panic_handler::{{closure}}::hfbf601f3d8c62d13
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/panicking.rs:651:13
  15:     0x7fb2cd417216 - std::sys_common::backtrace::__rust_end_short_backtrace::h98dd020b6e913806
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7fb2cd419a74 - rust_begin_unwind
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/panicking.rs:647:5
  17:     0x7fb2cd465e75 - core::panicking::panic_fmt::h0d3f1893e38be419
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/core/src/panicking.rs:72:14
  18:     0x7fb2cd465f33 - core::panicking::panic::h59297120e85ea178
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/core/src/panicking.rs:144:5
  19:     0x7fb2cbd584e5 - <rustc_span[9a816cd1dc398d83]::source_map::SourceMap>::lookup_char_pos
  20:     0x7fb2cc4fa5df - <rustc_errors[210c88760d7272a3]::emitter::FileWithAnnotatedLines>::collect_annotations
  21:     0x7fb2cc5b97a6 - <rustc_errors[210c88760d7272a3]::emitter::HumanEmitter>::emit_messages_default_inner::{closure#0}
  22:     0x7fb2cc2c88c0 - <rustc_errors[210c88760d7272a3]::emitter::HumanEmitter>::emit_messages_default
  23:     0x7fb2cc2c7b7a - <rustc_errors[210c88760d7272a3]::emitter::HumanEmitter as rustc_errors[210c88760d7272a3]::emitter::Emitter>::emit_diagnostic
  24:     0x7fb2cc4f37e6 - <rustc_errors[210c88760d7272a3]::DiagCtxtInner>::emit_diagnostic::{closure#2}
  25:     0x7fb2cc4f2113 - rustc_interface[aa0080c74e239226]::callbacks::track_diagnostic::{closure#0}
  26:     0x7fb2cc4f13d5 - rustc_interface[aa0080c74e239226]::callbacks::track_diagnostic
  27:     0x7fb2cc4f067b - <rustc_errors[210c88760d7272a3]::DiagCtxtInner>::emit_diagnostic
  28:     0x7fb2cc612ed2 - <rustc_errors[210c88760d7272a3]::DiagCtxt>::emit_diagnostic
  29:     0x7fb2cc62fa17 - <rustc_span[9a816cd1dc398d83]::ErrorGuaranteed as rustc_errors[210c88760d7272a3]::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
  30:     0x7fb2cbaaa02f - <rustc_hir_typeck[c9a6c5868c179bee]::fn_ctxt::FnCtxt>::check_block_with_expected
  31:     0x7fb2cc0853a2 - <rustc_hir_typeck[c9a6c5868c179bee]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  32:     0x7fb2cbef178e - rustc_hir_typeck[c9a6c5868c179bee]::check::check_fn
  33:     0x7fb2cc077f97 - rustc_hir_typeck[c9a6c5868c179bee]::typeck
  34:     0x7fb2cc0772b9 - rustc_query_impl[d4fff4934001d2d8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d4fff4934001d2d8]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b1822cca650065f0]::query::erase::Erased<[u8; 8usize]>>
  35:     0x7fb2cb8f73e2 - rustc_query_system[a6ec2c612bc0f18a]::query::plumbing::try_execute_query::<rustc_query_impl[d4fff4934001d2d8]::DynamicConfig<rustc_query_system[a6ec2c612bc0f18a]::query::caches::VecCache<rustc_span[9a816cd1dc398d83]::def_id::LocalDefId, rustc_middle[b1822cca650065f0]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[d4fff4934001d2d8]::plumbing::QueryCtxt, false>
  36:     0x7fb2cb8f7010 - rustc_query_impl[d4fff4934001d2d8]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7fb2cb8f4fb7 - rustc_hir_analysis[c457423c9d2f4f1c]::check_crate
  38:     0x7fb2cbfc93e6 - rustc_interface[aa0080c74e239226]::passes::analysis
  39:     0x7fb2cbfc8ddf - rustc_query_impl[d4fff4934001d2d8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d4fff4934001d2d8]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b1822cca650065f0]::query::erase::Erased<[u8; 1usize]>>
  40:     0x7fb2cc027034 - rustc_query_system[a6ec2c612bc0f18a]::query::plumbing::try_execute_query::<rustc_query_impl[d4fff4934001d2d8]::DynamicConfig<rustc_query_system[a6ec2c612bc0f18a]::query::caches::SingleCache<rustc_middle[b1822cca650065f0]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[d4fff4934001d2d8]::plumbing::QueryCtxt, false>
  41:     0x7fb2cc026e79 - rustc_query_impl[d4fff4934001d2d8]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  42:     0x7fb2cc2ea78b - rustc_interface[aa0080c74e239226]::interface::run_compiler::<core[853b3d1bf84aeb53]::result::Result<(), rustc_span[9a816cd1dc398d83]::ErrorGuaranteed>, rustc_driver_impl[f73d4ac0dd51449f]::run_compiler::{closure#0}>::{closure#0}
  43:     0x7fb2cc5382f1 - std[c78d3cd131ec7074]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[aa0080c74e239226]::util::run_in_thread_with_globals<rustc_interface[aa0080c74e239226]::interface::run_compiler<core[853b3d1bf84aeb53]::result::Result<(), rustc_span[9a816cd1dc398d83]::ErrorGuaranteed>, rustc_driver_impl[f73d4ac0dd51449f]::run_compiler::{closure#0}>::{closure#0}, core[853b3d1bf84aeb53]::result::Result<(), rustc_span[9a816cd1dc398d83]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[853b3d1bf84aeb53]::result::Result<(), rustc_span[9a816cd1dc398d83]::ErrorGuaranteed>>
  44:     0x7fb2cc53814f - <<std[c78d3cd131ec7074]::thread::Builder>::spawn_unchecked_<rustc_interface[aa0080c74e239226]::util::run_in_thread_with_globals<rustc_interface[aa0080c74e239226]::interface::run_compiler<core[853b3d1bf84aeb53]::result::Result<(), rustc_span[9a816cd1dc398d83]::ErrorGuaranteed>, rustc_driver_impl[f73d4ac0dd51449f]::run_compiler::{closure#0}>::{closure#0}, core[853b3d1bf84aeb53]::result::Result<(), rustc_span[9a816cd1dc398d83]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[853b3d1bf84aeb53]::result::Result<(), rustc_span[9a816cd1dc398d83]::ErrorGuaranteed>>::{closure#1} as core[853b3d1bf84aeb53]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  45:     0x7fb2cd423675 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4f08d401a486e446
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/alloc/src/boxed.rs:2015:9
  46:     0x7fb2cd423675 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3476dfcdba628abc
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/alloc/src/boxed.rs:2015:9
  47:     0x7fb2cd423675 - std::sys::pal::unix::thread::Thread::new::thread_start::h2770ac7f8882db09
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys/pal/unix/thread.rs:108:17
  48:     0x7fb2c7494ac3 - <unknown>
  49:     0x7fb2c7526850 - <unknown>
  50:                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: rustc 1.77.0 (aedd173a2 2024-03-17) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=1 -C llvm-args=--x86-asm-syntax=intel --crate-type rlib

query stack during panic:
#0 [typeck] type-checking `square`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0308`.
Compiler returned: 101

Backtrace

Don't know how to do that on godbolt

@Alcaro Alcaro 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 Apr 7, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 7, 2024
@compiler-errors compiler-errors self-assigned this Apr 7, 2024
@jieyouxu jieyouxu added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 7, 2024
@jieyouxu
Copy link
Member

jieyouxu commented Apr 7, 2024

This ICE'd as early as 1.38.0 lol https://godbolt.org/z/4o1P69Ed1

@matthiaskrgr
Copy link
Member

Greek Question Mark unwraps so hard the compiler crashes!

@bors bors closed this as completed in 4bc891a Apr 10, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 10, 2024
Rollup merge of rust-lang#123609 - compiler-errors:greek-question-mark, r=jieyouxu

Don't use bytepos offsets when computing semicolon span for removal

Causes problems when we recover confusable characters w/ a different byte width

Fixes rust-lang#123607
@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-diagnostics Area: Messages for errors, warnings, and lints 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) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue 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