Skip to content

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

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

Open
matthiaskrgr opened this issue Mar 28, 2025 · 3 comments
Labels
A-borrow-checker Area: The borrow checker A-error-handling Area: Error handling A-frontend Area: Compiler frontend (errors, parsing and HIR) A-parser Area: The lexing & parsing of Rust source code to an AST C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-bisection Status: a bisection has been found for this issue 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

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

pub fn foo3<'a>(_other: &'a [u8], x:Vec<&u8>, y: &u8) { x.push(y); } 

original:

pub fn foo(x: &mut Vec<&'a T>, y: Ref<'b>) { x.push(y); } //~ ERROR lifetime may not live long enough

pub fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); } //~ ERROR lifetime may not live long enough

pub fn foo3<'a>(_other: &'a [u8], x:Vec<&u8>, y: &u8) { x.push(y); } //~ ERROR lifetime may not live long enough

fn main() {}

Version information

rustc 1.87.0-nightly (2a0602295 2025-03-28)
binary: rustc
commit-hash: 2a06022951893fe5b5384f8dbd75b4e6e3b5cee0
commit-date: 2025-03-28
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.1

Possibly related line of code:

if mbc.pos < bpos {
// Every character is at least one byte, so we only
// count the actual extra bytes.
total_extra_bytes += mbc.bytes as u32 - 1;
// We should never see a byte position in the middle of a
// character.
assert!(bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32);
} else {
break;
}
}
assert!(total_extra_bytes <= bpos.to_u32());

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

Program output

error: unknown start of token: \u{ff06}
 --> /tmp/icemaker_global_tempdir.NM2ythOfXGaf/rustc_testrunner_tmpdir_reporting.uxIClsJjlvJ7/mvce.rs:5:38
  |
5 | pub fn foo3<'a>(_other: &'a [u8], x: & Vec<&u8>, y: &u8) { x.push(y); } 
  |                                      ^^
  |
help: Unicode character '&' (Fullwidth Ampersand) looks like '&' (Ampersand), but it is not
  |
5 - pub fn foo3<'a>(_other: &'a [u8], x: & Vec<&u8>, y: &u8) { x.push(y); } 
5 + pub fn foo3<'a>(_other: &'a [u8], x: & Vec<&u8>, y: &u8) { x.push(y); } 
  |

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.NM2ythOfXGaf/rustc_testrunner_tmpdir_reporting.uxIClsJjlvJ7/mvce.rs:5:72
  |
5 | pub fn foo3<'a>(_other: &'a [u8], x: & Vec<&u8>, y: &u8) { x.push(y); } 
  |                                                                         ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.NM2ythOfXGaf/rustc_testrunner_tmpdir_reporting.uxIClsJjlvJ7/mvce.rs`

error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
 --> /tmp/icemaker_global_tempdir.NM2ythOfXGaf/rustc_testrunner_tmpdir_reporting.uxIClsJjlvJ7/mvce.rs:5:60
  |
5 | pub fn foo3<'a>(_other: &'a [u8], x: & Vec<&u8>, y: &u8) { x.push(y); } 
  |                                                             ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
  |

thread 'rustc' panicked at compiler/rustc_span/src/lib.rs:2247:17:
assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32
stack backtrace:
   0:     0x7d4609077313 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hec1be6b515a4b985
   1:     0x7d4609805d91 - core::fmt::write::h1a721e23ea933c95
   2:     0x7d460ac8da51 - std::io::Write::write_fmt::h8aaeee0f3c8d3f0a
   3:     0x7d4609077172 - std::sys::backtrace::BacktraceLock::print::h5669ce1c06d4f78b
   4:     0x7d4609079a2a - std::panicking::default_hook::{{closure}}::h266748ebbae7c4be
   5:     0x7d46090795af - std::panicking::default_hook::hc3bb6e6c093f4ea4
   6:     0x7d46080e39b0 - std[4597d80d7047b022]::panicking::update_hook::<alloc[772d3812010e97a3]::boxed::Box<rustc_driver_impl[1d133c6972a1a6b9]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7d460907a2a3 - std::panicking::rust_panic_with_hook::h51ac92c4d270e86c
   8:     0x7d4609079f66 - std::panicking::begin_panic_handler::{{closure}}::h8eaa2cc0543eec41
   9:     0x7d46090777e9 - std::sys::backtrace::__rust_end_short_backtrace::h733c2f162ba57005
  10:     0x7d4609079c5d - __rustc[5fbf492971bd0060]::rust_begin_unwind
  11:     0x7d4605a92e70 - core::panicking::panic_fmt::h7438f3740b41962a
  12:     0x7d460671a4dc - core::panicking::panic::h654f603cc4632f97
  13:     0x7d460a0275c4 - <rustc_span[c4947a62e1591df3]::source_map::SourceMap>::lookup_char_pos
  14:     0x7d460a65f891 - <rustc_span[c4947a62e1591df3]::source_map::SourceMap>::is_valid_span
  15:     0x7d460a65fcfc - <core[d013d7c9d10039cf]::iter::adapters::filter_map::FilterMap<core[d013d7c9d10039cf]::iter::adapters::cloned::Cloned<core[d013d7c9d10039cf]::iter::adapters::filter::Filter<core[d013d7c9d10039cf]::slice::iter::Iter<rustc_errors[7964d5e4d9f7f11a]::Substitution>, <rustc_errors[7964d5e4d9f7f11a]::CodeSuggestion>::splice_lines::{closure#0}>>, <rustc_errors[7964d5e4d9f7f11a]::CodeSuggestion>::splice_lines::{closure#1}> as core[d013d7c9d10039cf]::iter::traits::iterator::Iterator>::next
  16:     0x7d460a662392 - <rustc_errors[7964d5e4d9f7f11a]::emitter::HumanEmitter>::emit_suggestion_default
  17:     0x7d460a01ed93 - <rustc_errors[7964d5e4d9f7f11a]::emitter::HumanEmitter as rustc_errors[7964d5e4d9f7f11a]::emitter::Emitter>::emit_diagnostic
  18:     0x7d460a66ff75 - <rustc_errors[7964d5e4d9f7f11a]::DiagCtxtInner>::emit_diagnostic::{closure#3}
  19:     0x7d460a672e4d - rustc_interface[838c222bb47cac2d]::callbacks::track_diagnostic::<core[d013d7c9d10039cf]::option::Option<rustc_span[c4947a62e1591df3]::ErrorGuaranteed>>
  20:     0x7d460a6719a2 - <rustc_errors[7964d5e4d9f7f11a]::DiagCtxtInner>::emit_diagnostic
  21:     0x7d460a67185f - <rustc_errors[7964d5e4d9f7f11a]::DiagCtxtHandle>::emit_diagnostic
  22:     0x7d460ac3dfea - <rustc_span[c4947a62e1591df3]::ErrorGuaranteed as rustc_errors[7964d5e4d9f7f11a]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  23:     0x7d460a9e8949 - rustc_borrowck[b30cfce8d6e8f762]::do_mir_borrowck
  24:     0x7d460a99aeec - rustc_query_impl[3289d2c66c00b6f8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3289d2c66c00b6f8]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8492cbf8fcfbb736]::query::erase::Erased<[u8; 8usize]>>
  25:     0x7d4609b3c96c - rustc_query_system[87ba3fee088a6fc4]::query::plumbing::try_execute_query::<rustc_query_impl[3289d2c66c00b6f8]::DynamicConfig<rustc_data_structures[44af7552550bcb5]::vec_cache::VecCache<rustc_span[c4947a62e1591df3]::def_id::LocalDefId, rustc_middle[8492cbf8fcfbb736]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[87ba3fee088a6fc4]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[3289d2c66c00b6f8]::plumbing::QueryCtxt, false>
  26:     0x7d4609b3c3cb - rustc_query_impl[3289d2c66c00b6f8]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  27:     0x7d460a142353 - rustc_interface[838c222bb47cac2d]::passes::run_required_analyses
  28:     0x7d460a21fc9e - rustc_interface[838c222bb47cac2d]::passes::analysis
  29:     0x7d460a21fc6d - rustc_query_impl[3289d2c66c00b6f8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3289d2c66c00b6f8]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8492cbf8fcfbb736]::query::erase::Erased<[u8; 0usize]>>
  30:     0x7d460a7bc3fd - rustc_query_system[87ba3fee088a6fc4]::query::plumbing::try_execute_query::<rustc_query_impl[3289d2c66c00b6f8]::DynamicConfig<rustc_query_system[87ba3fee088a6fc4]::query::caches::SingleCache<rustc_middle[8492cbf8fcfbb736]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[3289d2c66c00b6f8]::plumbing::QueryCtxt, false>
  31:     0x7d460a7bc0f8 - rustc_query_impl[3289d2c66c00b6f8]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7d460aac874d - rustc_interface[838c222bb47cac2d]::passes::create_and_enter_global_ctxt::<core[d013d7c9d10039cf]::option::Option<rustc_interface[838c222bb47cac2d]::queries::Linker>, rustc_driver_impl[1d133c6972a1a6b9]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  33:     0x7d460a9651aa - rustc_interface[838c222bb47cac2d]::interface::run_compiler::<(), rustc_driver_impl[1d133c6972a1a6b9]::run_compiler::{closure#0}>::{closure#1}
  34:     0x7d460a778148 - std[4597d80d7047b022]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[838c222bb47cac2d]::util::run_in_thread_with_globals<rustc_interface[838c222bb47cac2d]::util::run_in_thread_pool_with_globals<rustc_interface[838c222bb47cac2d]::interface::run_compiler<(), rustc_driver_impl[1d133c6972a1a6b9]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  35:     0x7d460a778a34 - <<std[4597d80d7047b022]::thread::Builder>::spawn_unchecked_<rustc_interface[838c222bb47cac2d]::util::run_in_thread_with_globals<rustc_interface[838c222bb47cac2d]::util::run_in_thread_pool_with_globals<rustc_interface[838c222bb47cac2d]::interface::run_compiler<(), rustc_driver_impl[1d133c6972a1a6b9]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[d013d7c9d10039cf]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  36:     0x7d460a779e37 - std::sys::pal::unix::thread::Thread::new::thread_start::h287c1faba384eaa8
  37:     0x7d46046a370a - <unknown>
  38:     0x7d4604727aac - <unknown>
  39:                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.87.0-nightly (2a0602295 2025-03-28) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_borrowck] borrow-checking `foo3`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0596, E0601.
For more information about an error, try `rustc --explain E0596`.

@matthiaskrgr matthiaskrgr 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 Mar 28, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 28, 2025
@matthiaskrgr
Copy link
Member Author

Regression in nightly-2024-02-09

  commit[0] 2024-02-07: Auto merge of #120748 - Nadrieril:rollup-dj0qwv5, r=Nadrieril
  commit[1] 2024-02-08: Auto merge of #120381 - fee1-dead-contrib:reconstify-add, r=compiler-errors
  commit[2] 2024-02-08: Auto merge of #120521 - reitermarkus:generic-nonzero-constructors, r=dtolnay
  commit[3] 2024-02-08: Auto merge of #120558 - oli-obk:missing_impl_item_ice, r=estebank
  commit[4] 2024-02-08: Auto merge of #120579 - GuillaumeGomez:prevent-running-unneeded-code, r=notriddle
  commit[5] 2024-02-08: Auto merge of #120550 - oli-obk:track_errors8, r=estebank
  commit[6] 2024-02-08: Auto merge of #120767 - matthiaskrgr:rollup-0k8ib1c, r=matthiaskrgr
  commit[7] 2024-02-08: Auto merge of #120544 - BoxyUwU:enter_forall, r=lcnr
  commit[8] 2024-02-08: Auto merge of #120807 - matthiaskrgr:rollup-1pf3glu, r=matthiaskrgr

@cyrgani
Copy link
Contributor

cyrgani commented Mar 28, 2025

smaller:

pub fn foo3(x:Vec<u8>) { x.push(0); } 

@moxian
Copy link
Contributor

moxian commented Mar 28, 2025

@rustbot label: +A-frontend +A-parser +A-borrow-checker +A-error-handling -needs-triage +S-has-mcve +S-has-bisection

@rustbot rustbot added A-borrow-checker Area: The borrow checker A-error-handling Area: Error handling A-frontend Area: Compiler frontend (errors, parsing and HIR) A-parser Area: The lexing & parsing of Rust source code to an AST S-has-bisection Status: a bisection has been found for this issue S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-borrow-checker Area: The borrow checker A-error-handling Area: Error handling A-frontend Area: Compiler frontend (errors, parsing and HIR) A-parser Area: The lexing & parsing of Rust source code to an AST C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-bisection Status: a bisection has been found for this issue 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

No branches or pull requests

4 participants