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: attempted to subtract with overflow with No-Break Space and small terminal #132918

Closed
matthiaskrgr opened this issue Nov 11, 2024 · 6 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. D-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. 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) ❄️ requires-debug-assertions This issue requires a build of rustc or tooling with debug-assertions in some way T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

                                         (                                        )

This mix of spaces and "no-break-spaces" https://www.compart.com/en/unicode/U+00A0 seems to cause a problem with small terminals when the terminal is too small to show the entire code as diagnostic.
I guess rustc has problems while splitting the no-break-spaces?

Meta

rustc --version --verbose:

de27914

Error output

output with sufficient screen space:

error: unknown start of token: \u{a0}
 --> a.rs:1:1
  |
1 | ...                   (                                        )
^ |
  |
help: Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is not
  |
1 |                                          (                                        )
  | +

error: expected item, found `(`
 --> a.rs:1:42
  |
1 | ...                   (                                        )
  |                       ^ expected item
  |
  = note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>

error: aborting due to 2 previous errors

output when terminal is node wide enough ( may require std overflow checks )

Backtrace

thread 'rustc' panicked at compiler/rustc_errors/src/emitter.rs:142:16:
attempt to subtract with overflow
stack backtrace:
   0:     0x7ba058cfda15 - std::backtrace_rs::backtrace::libunwind::trace::hce40cf0e2aac7ed5
                               at /home/matthias/vcs/github/rust/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7ba058cfda15 - std::backtrace_rs::backtrace::trace_unsynchronized::h880b379da68f72c2
                               at /home/matthias/vcs/github/rust/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ba058cfda15 - std::sys::backtrace::_print_fmt::h1a354c4aa782d172
                               at /home/matthias/vcs/github/rust/library/std/src/sys/backtrace.rs:66:9
   3:     0x7ba058cfda15 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h0d7ca387cd41cee9
                               at /home/matthias/vcs/github/rust/library/std/src/sys/backtrace.rs:39:26
   4:     0x7ba058d60733 - core::fmt::rt::Argument::fmt::he92dc2df83bef3f2
                               at /home/matthias/vcs/github/rust/library/core/src/fmt/rt.rs:177:76
   5:     0x7ba058d60733 - core::fmt::write::h591c6167c085ca3e
                               at /home/matthias/vcs/github/rust/library/core/src/fmt/mod.rs:1189:21
   6:     0x7ba058cf6b99 - std::io::Write::write_fmt::h21924ac1c814d024
                               at /home/matthias/vcs/github/rust/library/std/src/io/mod.rs:1839:15
   7:     0x7ba058cfd8b3 - std::sys::backtrace::BacktraceLock::print::hc19afe4d9960b9cf
                               at /home/matthias/vcs/github/rust/library/std/src/sys/backtrace.rs:42:9
   8:     0x7ba058cce4a7 - std::panicking::default_hook::{{closure}}::h062ece2733a4f22b
                               at /home/matthias/vcs/github/rust/library/std/src/panicking.rs:268:22
   9:     0x7ba058cce264 - std::panicking::default_hook::hb8b1f712abe85c4d
                               at /home/matthias/vcs/github/rust/library/std/src/panicking.rs:295:9
  10:     0x7ba054bfac08 - rustc_driver_impl[9029c07c6277fcfe]::install_ice_hook::{closure#0}
                               at /home/matthias/vcs/github/rust/compiler/rustc_driver_impl/src/lib.rs:1421:17
  11:     0x7ba054bfac08 - <alloc[acd64ee1b74bb5e0]::boxed::Box<rustc_driver_impl[9029c07c6277fcfe]::install_ice_hook::{closure#0}> as core[8de79deff3db24ef]::ops::function::Fn<(&dyn for<'a, 'b> core[8de79deff3db24ef]::ops::function::Fn<(&'a std[9f27a9e79a3d8fec]::panic::PanicHookInfo<'b>,), Output = ()> + core[8de79deff3db24ef]::marker::Send + core[8de79deff3db24ef]::marker::Sync, &std[9f27a9e79a3d8fec]::panic::PanicHookInfo)>>::call
                               at /home/matthias/vcs/github/rust/library/alloc/src/boxed.rs:1982:9
  12:     0x7ba058ccea9d - std::panicking::rust_panic_with_hook::hf5e74db3e2ab088b
                               at /home/matthias/vcs/github/rust/library/std/src/panicking.rs:809:13
  13:     0x7ba058cfdfd8 - std::panicking::begin_panic_handler::{{closure}}::he05440ad0bcf0762
                               at /home/matthias/vcs/github/rust/library/std/src/panicking.rs:667:13
  14:     0x7ba058cfdc49 - std::sys::backtrace::__rust_end_short_backtrace::h9c5bf8d13149dc49
                               at /home/matthias/vcs/github/rust/library/std/src/sys/backtrace.rs:170:18
  15:     0x7ba058cce54e - rust_begin_unwind
                               at /home/matthias/vcs/github/rust/library/std/src/panicking.rs:665:5
  16:     0x7ba054b9ca80 - core::panicking::panic_fmt::hb3d38ae66b53032c
                               at /home/matthias/vcs/github/rust/library/core/src/panicking.rs:76:14
  17:     0x7ba054b9d590 - core::panicking::panic_const::panic_const_sub_overflow::h7e9d53069202d422
                               at /home/matthias/vcs/github/rust/library/core/src/panicking.rs:182:21
  18:     0x7ba05880f5e9 - <rustc_errors[ba5f586387d3b915]::emitter::Margin>::compute
  19:     0x7ba05880f5e9 - <rustc_errors[ba5f586387d3b915]::emitter::Margin>::new
                               at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/emitter.rs:105:9
  20:     0x7ba05880f5e9 - <rustc_errors[ba5f586387d3b915]::emitter::HumanEmitter>::emit_messages_default_inner::{closure#0}
                               at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/emitter.rs:1771:30
  21:     0x7ba058807fd0 - <rustc_errors[ba5f586387d3b915]::emitter::HumanEmitter>::emit_messages_default_inner
                               at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/emitter.rs:1386:5
  22:     0x7ba0587fb509 - <rustc_errors[ba5f586387d3b915]::emitter::HumanEmitter>::emit_messages_default
                               at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/emitter.rs:2331:15
  23:     0x7ba0587fb509 - <rustc_errors[ba5f586387d3b915]::emitter::HumanEmitter as rustc_errors[ba5f586387d3b915]::emitter::Emitter>::emit_diagnostic
                               at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/emitter.rs:516:9
  24:     0x7ba05883070b - <rustc_errors[ba5f586387d3b915]::DiagCtxtInner>::emit_diagnostic::{closure#3}
                               at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/lib.rs:1572:17
  25:     0x7ba054f69cf2 - rustc_interface[37f1de6f39eeba1d]::callbacks::track_diagnostic::<core[8de79deff3db24ef]::option::Option<rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}
                               at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/callbacks.rs:53:13
  26:     0x7ba054f69cf2 - rustc_middle[b0f7bee8c2110bb2]::ty::context::tls::with_context_opt::<rustc_interface[37f1de6f39eeba1d]::callbacks::track_diagnostic<core[8de79deff3db24ef]::option::Option<rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::option::Option<rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>
                               at /home/matthias/vcs/github/rust/compiler/rustc_middle/src/ty/context/tls.rs:95:9
  27:     0x7ba054f69cf2 - rustc_interface[37f1de6f39eeba1d]::callbacks::track_diagnostic::<core[8de79deff3db24ef]::option::Option<rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>
                               at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/callbacks.rs:42:5
  28:     0x7ba05882fa61 - <rustc_errors[ba5f586387d3b915]::DiagCtxtInner>::emit_diagnostic
                               at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/lib.rs:1527:9
  29:     0x7ba05882e5c8 - <rustc_errors[ba5f586387d3b915]::DiagCtxtHandle>::emit_diagnostic
                               at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/lib.rs:1057:9
  30:     0x7ba058881e45 - <rustc_errors[ba5f586387d3b915]::diagnostic::Diag>::emit_producing_error_guaranteed
                               at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/diagnostic.rs:1324:20
  31:     0x7ba0582408fe - <rustc_errors[ba5f586387d3b915]::diagnostic::Diag>::emit
                               at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/diagnostic.rs:1331:9
  32:     0x7ba0582408fe - <rustc_errors[ba5f586387d3b915]::DiagCtxtHandle>::emit_err::<rustc_parse[a0515389a56242fe]::errors::UnknownTokenStart>
                               at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/lib.rs:1262:30
  33:     0x7ba0582408fe - <rustc_parse[a0515389a56242fe]::lexer::StringReader>::next_token
                               at /home/matthias/vcs/github/rust/compiler/rustc_parse/src/lexer/mod.rs:390:32
  34:     0x7ba05822fc5c - <rustc_parse[a0515389a56242fe]::lexer::tokentrees::TokenTreesReader>::bump
                               at /home/matthias/vcs/github/rust/compiler/rustc_parse/src/lexer/tokentrees.rs:223:66
  35:     0x7ba05822fc5c - <rustc_parse[a0515389a56242fe]::lexer::tokentrees::TokenTreesReader>::lex_token_trees
                               at /home/matthias/vcs/github/rust/compiler/rustc_parse/src/lexer/tokentrees.rs:41:33
  36:     0x7ba05822fa9d - <rustc_parse[a0515389a56242fe]::lexer::tokentrees::TokenTreesReader>::lex_all_token_trees
                               at /home/matthias/vcs/github/rust/compiler/rustc_parse/src/lexer/tokentrees.rs:30:44
  37:     0x7ba05823fa6e - rustc_parse[a0515389a56242fe]::lexer::lex_token_trees
                               at /home/matthias/vcs/github/rust/compiler/rustc_parse/src/lexer/mod.rs:70:9
  38:     0x7ba058223698 - rustc_parse[a0515389a56242fe]::source_file_to_stream
                               at /home/matthias/vcs/github/rust/compiler/rustc_parse/src/lib.rs:125:5
  39:     0x7ba05822349f - rustc_parse[a0515389a56242fe]::new_parser_from_source_file
                               at /home/matthias/vcs/github/rust/compiler/rustc_parse/src/lib.rs:93:18
  40:     0x7ba058223116 - rustc_parse[a0515389a56242fe]::new_parser_from_file
                               at /home/matthias/vcs/github/rust/compiler/rustc_parse/src/lib.rs:83:5
  41:     0x7ba054f42893 - rustc_interface[37f1de6f39eeba1d]::passes::parse::{closure#0}
                               at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/passes.rs:48:38
  42:     0x7ba054f42893 - <rustc_data_structures[df9e5fd32402cd55]::profiling::VerboseTimingGuard>::run::<core[8de79deff3db24ef]::result::Result<rustc_ast[bcfd8b886c650e0d]::ast::Crate, rustc_errors[ba5f586387d3b915]::diagnostic::Diag>, rustc_interface[37f1de6f39eeba1d]::passes::parse::{closure#0}>
                               at /home/matthias/vcs/github/rust/compiler/rustc_data_structures/src/profiling.rs:753:9
  43:     0x7ba054f42893 - <rustc_session[b89f9ebcd63b92ca]::session::Session>::time::<core[8de79deff3db24ef]::result::Result<rustc_ast[bcfd8b886c650e0d]::ast::Crate, rustc_errors[ba5f586387d3b915]::diagnostic::Diag>, rustc_interface[37f1de6f39eeba1d]::passes::parse::{closure#0}>
                               at /home/matthias/vcs/github/rust/compiler/rustc_session/src/utils.rs:16:9
  44:     0x7ba054ecdbff - rustc_interface[37f1de6f39eeba1d]::passes::parse
                               at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/passes.rs:45:17
  45:     0x7ba054f6b0b4 - <rustc_interface[37f1de6f39eeba1d]::queries::Queries>::parse::{closure#0}
                               at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/queries.rs:98:31
  46:     0x7ba054f6b0b4 - <rustc_interface[37f1de6f39eeba1d]::queries::Query<rustc_ast[bcfd8b886c650e0d]::ast::Crate>>::compute::<<rustc_interface[37f1de6f39eeba1d]::queries::Queries>::parse::{closure#0}>::{closure#0}::{closure#0}
                               at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/queries.rs:39:41
  47:     0x7ba054f6b0b4 - <core[8de79deff3db24ef]::option::Option<core[8de79deff3db24ef]::result::Result<rustc_data_structures[df9e5fd32402cd55]::steal::Steal<rustc_ast[bcfd8b886c650e0d]::ast::Crate>, rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>>::get_or_insert_with::<<rustc_interface[37f1de6f39eeba1d]::queries::Query<rustc_ast[bcfd8b886c650e0d]::ast::Crate>>::compute<<rustc_interface[37f1de6f39eeba1d]::queries::Queries>::parse::{closure#0}>::{closure#0}::{closure#0}>
                               at /home/matthias/vcs/github/rust/library/core/src/option.rs:1690:26
  48:     0x7ba054f6b0b4 - <rustc_interface[37f1de6f39eeba1d]::queries::Query<rustc_ast[bcfd8b886c650e0d]::ast::Crate>>::compute::<<rustc_interface[37f1de6f39eeba1d]::queries::Queries>::parse::{closure#0}>::{closure#0}
                               at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/queries.rs:39:17
  49:     0x7ba054f6b0b4 - <core[8de79deff3db24ef]::cell::RefMut<core[8de79deff3db24ef]::option::Option<core[8de79deff3db24ef]::result::Result<rustc_data_structures[df9e5fd32402cd55]::steal::Steal<rustc_ast[bcfd8b886c650e0d]::ast::Crate>, rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>>>::filter_map::<rustc_data_structures[df9e5fd32402cd55]::steal::Steal<rustc_ast[bcfd8b886c650e0d]::ast::Crate>, <rustc_interface[37f1de6f39eeba1d]::queries::Query<rustc_ast[bcfd8b886c650e0d]::ast::Crate>>::compute<<rustc_interface[37f1de6f39eeba1d]::queries::Queries>::parse::{closure#0}>::{closure#0}>
                               at /home/matthias/vcs/github/rust/library/core/src/cell.rs:1713:15
  50:     0x7ba054f6b0b4 - <rustc_interface[37f1de6f39eeba1d]::queries::Query<rustc_ast[bcfd8b886c650e0d]::ast::Crate>>::compute::<<rustc_interface[37f1de6f39eeba1d]::queries::Queries>::parse::{closure#0}>
                               at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/queries.rs:36:9
  51:     0x7ba054f6b0b4 - <rustc_interface[37f1de6f39eeba1d]::queries::Queries>::parse
                               at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/queries.rs:98:9
  52:     0x7ba054c30fb1 - rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}::{closure#1}
                               at /home/matthias/vcs/github/rust/compiler/rustc_driver_impl/src/lib.rs:398:13
  53:     0x7ba054c30fb1 - <rustc_interface[37f1de6f39eeba1d]::interface::Compiler>::enter::<rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}::{closure#1}, core[8de79deff3db24ef]::result::Result<core[8de79deff3db24ef]::option::Option<rustc_interface[37f1de6f39eeba1d]::queries::Linker>, rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>
                               at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/queries.rs:210:19
  54:     0x7ba054c4c5f1 - rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}
                               at /home/matthias/vcs/github/rust/compiler/rustc_driver_impl/src/lib.rs:393:22
  55:     0x7ba054c4c5f1 - rustc_interface[37f1de6f39eeba1d]::interface::run_compiler::<core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}
                               at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/interface.rs:505:27
  56:     0x7ba054c4c5f1 - rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_pool_with_globals::<rustc_interface[37f1de6f39eeba1d]::interface::run_compiler<core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}
                               at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/util.rs:157:13
  57:     0x7ba054c4c5f1 - rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_with_globals::<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_pool_with_globals<rustc_interface[37f1de6f39eeba1d]::interface::run_compiler<core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}
                               at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/util.rs:107:21
  58:     0x7ba054c4c5f1 - <scoped_tls[8fc6cf398c575fa5]::ScopedKey<rustc_span[e1ef1ea18f9f3be]::SessionGlobals>>::set::<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_with_globals<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_pool_with_globals<rustc_interface[37f1de6f39eeba1d]::interface::run_compiler<core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>
                               at /home/matthias/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scoped-tls-1.0.1/src/lib.rs:137:9
  59:     0x7ba054c4c5f1 - rustc_span[e1ef1ea18f9f3be]::create_session_globals_then::<core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>, rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_with_globals<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_pool_with_globals<rustc_interface[37f1de6f39eeba1d]::interface::run_compiler<core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}>
                               at /home/matthias/vcs/github/rust/compiler/rustc_span/src/lib.rs:137:5
  60:     0x7ba054bb43f1 - rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_with_globals::<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_pool_with_globals<rustc_interface[37f1de6f39eeba1d]::interface::run_compiler<core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}
                               at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/util.rs:106:17
  61:     0x7ba054bb43f1 - std[9f27a9e79a3d8fec]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_with_globals<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_pool_with_globals<rustc_interface[37f1de6f39eeba1d]::interface::run_compiler<core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>
                               at /home/matthias/vcs/github/rust/library/std/src/sys/backtrace.rs:154:18
  62:     0x7ba054bb5977 - <std[9f27a9e79a3d8fec]::thread::Builder>::spawn_unchecked_::<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_with_globals<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_pool_with_globals<rustc_interface[37f1de6f39eeba1d]::interface::run_compiler<core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#1}::{closure#0}
                               at /home/matthias/vcs/github/rust/library/std/src/thread/mod.rs:541:17
  63:     0x7ba054bb5977 - <core[8de79deff3db24ef]::panic::unwind_safe::AssertUnwindSafe<<std[9f27a9e79a3d8fec]::thread::Builder>::spawn_unchecked_<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_with_globals<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_pool_with_globals<rustc_interface[37f1de6f39eeba1d]::interface::run_compiler<core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#1}::{closure#0}> as core[8de79deff3db24ef]::ops::function::FnOnce<()>>::call_once
                               at /home/matthias/vcs/github/rust/library/core/src/panic/unwind_safe.rs:272:9
  64:     0x7ba054bb5977 - std[9f27a9e79a3d8fec]::panicking::try::do_call::<core[8de79deff3db24ef]::panic::unwind_safe::AssertUnwindSafe<<std[9f27a9e79a3d8fec]::thread::Builder>::spawn_unchecked_<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_with_globals<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_pool_with_globals<rustc_interface[37f1de6f39eeba1d]::interface::run_compiler<core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#1}::{closure#0}>, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>
                               at /home/matthias/vcs/github/rust/library/std/src/panicking.rs:557:40
  65:     0x7ba054bb5977 - std[9f27a9e79a3d8fec]::panicking::try::<core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>, core[8de79deff3db24ef]::panic::unwind_safe::AssertUnwindSafe<<std[9f27a9e79a3d8fec]::thread::Builder>::spawn_unchecked_<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_with_globals<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_pool_with_globals<rustc_interface[37f1de6f39eeba1d]::interface::run_compiler<core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#1}::{closure#0}>>
                               at /home/matthias/vcs/github/rust/library/std/src/panicking.rs:520:19
  66:     0x7ba054bb5977 - std[9f27a9e79a3d8fec]::panic::catch_unwind::<core[8de79deff3db24ef]::panic::unwind_safe::AssertUnwindSafe<<std[9f27a9e79a3d8fec]::thread::Builder>::spawn_unchecked_<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_with_globals<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_pool_with_globals<rustc_interface[37f1de6f39eeba1d]::interface::run_compiler<core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#1}::{closure#0}>, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>
                               at /home/matthias/vcs/github/rust/library/std/src/panic.rs:358:14
  67:     0x7ba054bb5977 - <std[9f27a9e79a3d8fec]::thread::Builder>::spawn_unchecked_::<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_with_globals<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_pool_with_globals<rustc_interface[37f1de6f39eeba1d]::interface::run_compiler<core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#1}
                               at /home/matthias/vcs/github/rust/library/std/src/thread/mod.rs:540:30
  68:     0x7ba054bb5977 - <<std[9f27a9e79a3d8fec]::thread::Builder>::spawn_unchecked_<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_with_globals<rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_pool_with_globals<rustc_interface[37f1de6f39eeba1d]::interface::run_compiler<core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#1} as core[8de79deff3db24ef]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
                               at /home/matthias/vcs/github/rust/library/core/src/ops/function.rs:250:5
  69:     0x7ba058ce1643 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3425f4d14c8f80b0
                               at /home/matthias/vcs/github/rust/library/alloc/src/boxed.rs:1968:9
  70:     0x7ba058ce1643 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb4c2e9fcaaea9e84
                               at /home/matthias/vcs/github/rust/library/alloc/src/boxed.rs:1968:9
  71:     0x7ba058ce1643 - std::sys::pal::unix::thread::Thread::new::thread_start::hbf5605cef6cbee26
                               at /home/matthias/vcs/github/rust/library/std/src/sys/pal/unix/thread.rs:105:17
  72:     0x7ba053ea339d - <unknown>
  73:     0x7ba053f2849c - <unknown>
  74:                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: please attach the file at `/tmp/im/rustc-ice-2024-11-11T20_55_45-1497449.txt` to your bug report

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

@matthiaskrgr matthiaskrgr added A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-debug-assertions This issue requires a build of rustc or tooling with debug-assertions in some way T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 11, 2024
@matthiaskrgr
Copy link
Member Author

a.rs.txt

@fmease fmease added D-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. D-Unicode-unaware Diagnostics: Diagnostics that are unaware of Unicode and trigger codepoint boundary assertions labels Nov 11, 2024
@harrisonkaiser
Copy link

I'm not able to replicate this issue. rustc +stage1 a.rs.txt seems to always work no matter what width or height I make the terminal (I used screen to get down to a 1x1 terminal window). I've tried both on the most recent nightly (f1ec5d6) and the de27914. No matter how I size the terminal the message appears as expected.

Do you have more information on how to replicate the overflow?

@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Dec 15, 2024

did you build rustc with debug assertions?

edit: may need rustc debug assertions as well as std debug assertions

@harrisonkaiser
Copy link

harrisonkaiser commented Dec 16, 2024

My Original PR (#134361) changes things to work as follows:

Wide Terminal:

error: unknown start of token: \u{a0}
 --> ../132918/a.rs.txt:1:1
  |
1 | ...                   (                                        )
^ |
  |
help: Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is not
  |
1 |                                          (                                        )
  | +

error: expected item, found `(`
 --> ../132918/a.rs.txt:1:42
  |
1 | ...                   (                                        )
  |                       ^ expected item
  |
  = note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>

error: aborting due to 2 previous errors

Skinny Terminal:

error: unknown start of token: \u{a0}
 --> ../132918/a.rs.txt:1:1
  |
1 |                                          ( ...
  | ^
  |
help: Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is not
  |
1 |                                          (                                        )
  | +

error: expected item, found `(`
 --> ../132918/a.rs.txt:1:42
  |
1 | ...   (                                    ...
  |       ^ expected item
  |
  = note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>

error: aborting due to 2 previous errors

My question is, for a skinny terminal where is the ^ meant to be in the first error?

The expected output posted previously has it to the left of the | as does the wide terminal output. My PR causes it to move (in the case of a skinny terminal) to the right of the | as if it is pointing at the first character where the NBS exists.

Indeed if I add 7 spaces before to the beginning of the file and repeat the the experiment with the wide and skinny terminal:
Wide:

error: unknown start of token: \u{a0}
 --> ../132918/sevenSpace.rs:1:8
  |
1 | ...                   (                                        )
^ |
  |
help: Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is not
  |
1 |                                                 (                                        )
  |        +

error: expected item, found `(`
 --> ../132918/sevenSpace.rs:1:49
  |
1 | ...                   (                                        )
  |                       ^ expected item
  |
  = note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>

error: aborting due to 2 previous errors

Skinny:

error: unknown start of token: \u{a0}
 --> ../132918/sevenSpace.rs:1:8
  |
1 |                                            ...
  |        ^
  |
help: Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is not
  |
1 |                                                 (                                        )
  |        +

error: expected item, found `(`
 --> ../132918/sevenSpace.rs:1:49
  |
1 | ...   (                                    ...
  |       ^ expected item
  |
  = note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>

error: aborting due to 2 previous errors

The same thing happens, but now offset 7 characters.

If the ^ is meant to point at the line number, then my Original PR ( #134361 ) exposes a bug with a different code path, that we take as a result of the change. If the ^ is meant to point at the erroneous \u{a0} then it being to the left of the | was always a bug. Which is it meant to be?

@harrisonkaiser
Copy link

Upon further investigation: I'm now fairly certain that ^ is not meant to label the line number, and should label the non-breaking space.

The problem, I discovered is in the logic around what counts as leading white-space. The overflowing subtraction assumes that no errors will occur inside the leading whitespace. However it computes the length of that whitespace with std::char::is_whitespace and not rustc_lexer::is_whitespace. The former include no-break space and the later excludes it. We can only safely make the assumption that no errors occur in whitespace if it is all "Rust Standard" whitespace. Indeed an error does occur in unicode whitespace (if there is a no-break space).

DianQK added a commit to DianQK/rust that referenced this issue Dec 20, 2024
…avidtwco

Fix logical error with what text is considered whitespace.

There appears to be a logical issue around what counts as leading white-space. There is code which does a subtraction assuming that no errors will be reported inside the leading whitespace. However we compute the length of that whitespace with std::char::is_whitespace and not rustc_lexer::is_whitespace. The former will include a no-break space while later will excluded it. We can only safely make the assumption that no errors will be reported  in whitespace if it is all "Rust Standard" whitespace. Indeed an error does occur in unicode whitespace if it contains a no-break space. In that case the subtraction will cause a ICE (for a compiler in debug mode) as described in rust-lang#132918.
jieyouxu added a commit to jieyouxu/rust that referenced this issue Dec 20, 2024
…avidtwco

Fix logical error with what text is considered whitespace.

There appears to be a logical issue around what counts as leading white-space. There is code which does a subtraction assuming that no errors will be reported inside the leading whitespace. However we compute the length of that whitespace with std::char::is_whitespace and not rustc_lexer::is_whitespace. The former will include a no-break space while later will excluded it. We can only safely make the assumption that no errors will be reported  in whitespace if it is all "Rust Standard" whitespace. Indeed an error does occur in unicode whitespace if it contains a no-break space. In that case the subtraction will cause a ICE (for a compiler in debug mode) as described in rust-lang#132918.
jieyouxu added a commit to jieyouxu/rust that referenced this issue Dec 20, 2024
…avidtwco

Fix logical error with what text is considered whitespace.

There appears to be a logical issue around what counts as leading white-space. There is code which does a subtraction assuming that no errors will be reported inside the leading whitespace. However we compute the length of that whitespace with std::char::is_whitespace and not rustc_lexer::is_whitespace. The former will include a no-break space while later will excluded it. We can only safely make the assumption that no errors will be reported  in whitespace if it is all "Rust Standard" whitespace. Indeed an error does occur in unicode whitespace if it contains a no-break space. In that case the subtraction will cause a ICE (for a compiler in debug mode) as described in rust-lang#132918.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 20, 2024
Rollup merge of rust-lang#134366 - harrisonkaiser:no-break-space, r=davidtwco

Fix logical error with what text is considered whitespace.

There appears to be a logical issue around what counts as leading white-space. There is code which does a subtraction assuming that no errors will be reported inside the leading whitespace. However we compute the length of that whitespace with std::char::is_whitespace and not rustc_lexer::is_whitespace. The former will include a no-break space while later will excluded it. We can only safely make the assumption that no errors will be reported  in whitespace if it is all "Rust Standard" whitespace. Indeed an error does occur in unicode whitespace if it contains a no-break space. In that case the subtraction will cause a ICE (for a compiler in debug mode) as described in rust-lang#132918.
@harrisonkaiser
Copy link

Fixed in #134366

github-actions bot pushed a commit to rust-lang/miri that referenced this issue Dec 21, 2024
Fix logical error with what text is considered whitespace.

There appears to be a logical issue around what counts as leading white-space. There is code which does a subtraction assuming that no errors will be reported inside the leading whitespace. However we compute the length of that whitespace with std::char::is_whitespace and not rustc_lexer::is_whitespace. The former will include a no-break space while later will excluded it. We can only safely make the assumption that no errors will be reported  in whitespace if it is all "Rust Standard" whitespace. Indeed an error does occur in unicode whitespace if it contains a no-break space. In that case the subtraction will cause a ICE (for a compiler in debug mode) as described in rust-lang/rust#132918.
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-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. 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) ❄️ requires-debug-assertions This issue requires a build of rustc or tooling with debug-assertions in some way T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants