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: assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32 #129503

Closed
matthiaskrgr opened this issue Aug 24, 2024 · 2 comments · Fixed by #130917
Closed

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

matthiaskrgr opened this issue Aug 24, 2024 · 2 comments · Fixed by #130917
Labels
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-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

use std::arch::asm;

unsafe fn f6() {
    asm!(concat!(r#"lJ𐏿Æ�.𐏿�"#, "r} {}"));
}

original:

// Ensure inout asm! operands are marked as used by the liveness pass

//@ only-x86_64
//@ check-pass

#![allow(dead_code)]
#![warn(unused_assignments)]
#![warn(unused_variables)]

use std::arch::asm;

// Test the single inout case
unsafe fn f1(mut src: *const u8) {
    asm!("/*{0}*/b", inout(reg) src); //~ WARN value assigned to `src` is never read
}

unsafe fn f2(mut src: *const u8) -> *const u8 {
    asm!("/*{0}*/", inout(ComplexTup, 0 . 0.1.) src);
    src
}

// Test the split inout case
unsafe fn f3(mut src: *const u8) {
    asm!("/*{0}*/", inout(reg) src => src); //~ WARN value assigned to `src` is never read
}

unsafe fn f4(mut src: *const u8) -> *const u8 {
    asm!(c"/*{0}*/", weird_hygiene(reg) src => src);
    src
}

// Tests the use of field projections
struct S {
    field: *mut u8,
}

unsafe fn f5(src: &mut S) {
    asm!("/*{0}*/", inout(reg) src.field);
}

unsafe fn f6(src: &mut S) {
    asm!( concat ! ( r#"lJ𐏿Æ�.𐏿�"# , "r} {}" )     );
}

fn main() {}

Version information

rustc 1.82.0-nightly (edbc000fa 2024-08-24)
binary: rustc
commit-hash: edbc000fa4413f9ff92f4e5492f8ff497716ce48
commit-date: 2024-08-24
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0

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

Program output

thread 'rustc' panicked at compiler/rustc_span/src/lib.rs:2028:17:
assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32
stack backtrace:
   0:     0x7509459d6ebd - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hbbce437f95729b37
   1:     0x750946204c97 - core::fmt::write::h21e51fc45e851977
   2:     0x7509471b7a11 - std::io::Write::write_fmt::h7cbeab9f6ab42ce3
   3:     0x7509459d959b - std::panicking::default_hook::{{closure}}::h060ecf4ec754efbe
   4:     0x7509459d920e - std::panicking::default_hook::h23b9da54a073e9e1
   5:     0x750944b52f89 - std[5c43df6f1c3208ff]::panicking::update_hook::<alloc[34541d82da33361]::boxed::Box<rustc_driver_impl[2d5acae0b271c880]::install_ice_hook::{closure#0}>>::{closure#0}
   6:     0x7509459d9eb7 - std::panicking::rust_panic_with_hook::h143e179a7cc018c2
   7:     0x7509459d9b43 - std::panicking::begin_panic_handler::{{closure}}::hfe4ad1ee631377dc
   8:     0x7509459d7379 - std::sys::backtrace::__rust_end_short_backtrace::hc554e2748840d46e
   9:     0x7509459d9844 - rust_begin_unwind
  10:     0x750942bd3fc3 - core::panicking::panic_fmt::h27f74798f8132652
  11:     0x750942a7e2dc - core::panicking::panic::h792739f7b952660b
  12:     0x75094354bca4 - <rustc_span[694568e5274b44f6]::source_map::SourceMap>::lookup_char_pos
  13:     0x750947418e50 - <rustc_errors[595a87896474165e]::emitter::HumanEmitter>::get_multispan_max_line_num
  14:     0x75094741ff60 - <rustc_errors[595a87896474165e]::emitter::HumanEmitter>::emit_messages_default
  15:     0x750947409469 - <rustc_errors[595a87896474165e]::emitter::HumanEmitter as rustc_errors[595a87896474165e]::emitter::Emitter>::emit_diagnostic
  16:     0x75094740a8c1 - <rustc_errors[595a87896474165e]::DiagCtxtInner>::emit_diagnostic::{closure#3}
  17:     0x75094740de19 - rustc_interface[cacb1ddf69907e5b]::callbacks::track_diagnostic::<core[bb4a83b08ce1f593]::option::Option<rustc_span[694568e5274b44f6]::ErrorGuaranteed>>
  18:     0x75094740c23e - <rustc_errors[595a87896474165e]::DiagCtxtInner>::emit_diagnostic
  19:     0x75094740c0dd - <rustc_errors[595a87896474165e]::DiagCtxtHandle>::emit_diagnostic
  20:     0x75094749968b - <rustc_span[694568e5274b44f6]::ErrorGuaranteed as rustc_errors[595a87896474165e]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  21:     0x75094498217f - rustc_builtin_macros[55e9f49dc2d92829]::asm::expand_preparsed_asm
  22:     0x750944982c62 - rustc_builtin_macros[55e9f49dc2d92829]::asm::expand_asm
  23:     0x7509426bd08e - <rustc_expand[7ac319ded11d3fcf]::expand::MacroExpander>::fully_expand_fragment
  24:     0x75094738131f - <rustc_expand[7ac319ded11d3fcf]::expand::MacroExpander>::expand_crate
  25:     0x7509467480a7 - rustc_interface[cacb1ddf69907e5b]::passes::resolver_for_lowering_raw
  26:     0x75094674764d - rustc_query_impl[dda391671c843dbe]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[dda391671c843dbe]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[550de35c81b7c220]::query::erase::Erased<[u8; 16usize]>>
  27:     0x750946747635 - <rustc_query_impl[dda391671c843dbe]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[bb4a83b08ce1f593]::ops::function::FnOnce<(rustc_middle[550de35c81b7c220]::ty::context::TyCtxt, ())>>::call_once
  28:     0x750947169f52 - rustc_query_system[547d19ae72793cb3]::query::plumbing::try_execute_query::<rustc_query_impl[dda391671c843dbe]::DynamicConfig<rustc_query_system[547d19ae72793cb3]::query::caches::SingleCache<rustc_middle[550de35c81b7c220]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[dda391671c843dbe]::plumbing::QueryCtxt, false>
  29:     0x750947169bed - rustc_query_impl[dda391671c843dbe]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  30:     0x750946ff94de - rustc_interface[cacb1ddf69907e5b]::interface::run_compiler::<core[bb4a83b08ce1f593]::result::Result<(), rustc_span[694568e5274b44f6]::ErrorGuaranteed>, rustc_driver_impl[2d5acae0b271c880]::run_compiler::{closure#0}>::{closure#1}
  31:     0x75094705d8d0 - std[5c43df6f1c3208ff]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[cacb1ddf69907e5b]::util::run_in_thread_with_globals<rustc_interface[cacb1ddf69907e5b]::util::run_in_thread_pool_with_globals<rustc_interface[cacb1ddf69907e5b]::interface::run_compiler<core[bb4a83b08ce1f593]::result::Result<(), rustc_span[694568e5274b44f6]::ErrorGuaranteed>, rustc_driver_impl[2d5acae0b271c880]::run_compiler::{closure#0}>::{closure#1}, core[bb4a83b08ce1f593]::result::Result<(), rustc_span[694568e5274b44f6]::ErrorGuaranteed>>::{closure#0}, core[bb4a83b08ce1f593]::result::Result<(), rustc_span[694568e5274b44f6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[bb4a83b08ce1f593]::result::Result<(), rustc_span[694568e5274b44f6]::ErrorGuaranteed>>
  32:     0x75094705df3a - <<std[5c43df6f1c3208ff]::thread::Builder>::spawn_unchecked_<rustc_interface[cacb1ddf69907e5b]::util::run_in_thread_with_globals<rustc_interface[cacb1ddf69907e5b]::util::run_in_thread_pool_with_globals<rustc_interface[cacb1ddf69907e5b]::interface::run_compiler<core[bb4a83b08ce1f593]::result::Result<(), rustc_span[694568e5274b44f6]::ErrorGuaranteed>, rustc_driver_impl[2d5acae0b271c880]::run_compiler::{closure#0}>::{closure#1}, core[bb4a83b08ce1f593]::result::Result<(), rustc_span[694568e5274b44f6]::ErrorGuaranteed>>::{closure#0}, core[bb4a83b08ce1f593]::result::Result<(), rustc_span[694568e5274b44f6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[bb4a83b08ce1f593]::result::Result<(), rustc_span[694568e5274b44f6]::ErrorGuaranteed>>::{closure#1} as core[bb4a83b08ce1f593]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x75094705e2ab - std::sys::pal::unix::thread::Thread::new::thread_start::h8ebe34582a25d2ab
  34:     0x75094878439d - <unknown>
  35:     0x75094880949c - <unknown>
  36:                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.82.0-nightly (edbc000fa 2024-08-24) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack
error: aborting due to 1 previous error


@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 Aug 24, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 24, 2024
@fmease fmease added D-Unicode-unaware Diagnostics: Diagnostics that are unaware of Unicode and trigger codepoint boundary assertions and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Aug 24, 2024
@jieyouxu

This comment was marked as outdated.

@jieyouxu
Copy link
Member

jieyouxu commented Aug 24, 2024

(without looking at the code, is it - BytePos(1)?)
EDIT: ah no this might be the other class of macro-related unicode troubles, seems similar to #114865

@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Sep 1, 2024
@bors bors closed this as completed in 01fecf6 Sep 27, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Sep 27, 2024
Rollup merge of rust-lang#130917 - gurry:129503-ice-wrong-span-in-macros, r=chenyukang

Fix error span if arg to `asm!()` is a macro call

Fixes rust-lang#129503

When the argument to `asm!()` is a macro call, e.g. `asm!(concat!("abc", "{} pqr"))`, and there's an error in the resulting template string, we do not take into account the presence of this macro call while computing the error span. This PR fixes that. Now we will use the entire thing between the parenthesis of `asm!()` as the error span in this situation e.g. for `asm!(concat!("abc", "{} pqr"))` the error span will be `concat!("abc", "{} pqr")`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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.

4 participants