Unsoundness and ICE due to string literals that are too long for a 32-bit platform
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
I obtained the ICE by compiling with RUST_BACKTRACE=1 cargo check --target=i686-unknown-linux-gnu. Notably, this target is a 32-bit system.
The file src/blank.txt is a file containing 2,000,000,000 space characters. The below code is in src/lib.rs.
pub const X: &str = concat!(
include_str!("blank.txt"),
include_str!("blank.txt"),
include_str!("blank.txt")
);
Meta
rustc --version --verbose:
rustc 1.97.0-nightly (7c3c88f42 2026-05-14)
binary: rustc
commit-hash: 7c3c88f42ad444f4688b865591d84660be4ece2f
commit-date: 2026-05-14
host: aarch64-apple-darwin
release: 1.97.0-nightly
LLVM version: 22.1.4
Error output
error: internal compiler error: /rustc-dev/7c3c88f42ad444f4688b865591d84660be4ece2f/compiler/rustc_middle/src/mir/interpret/value.rs:139:32: Unsigned value 0x165a0bc00 does not fit in 32 bits
Backtrace
thread 'rustc' (170554) panicked at /rustc-dev/7c3c88f42ad444f4688b865591d84660be4ece2f/compiler/rustc_middle/src/mir/interpret/value.rs:139:32:
Box<dyn Any>
stack backtrace:
0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
2: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
3: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
5: rustc_middle::util::bug::bug_fmt
6: <rustc_middle::mir::interpret::value::Scalar<rustc_middle::mir::interpret::AllocId>>::from_uint::<u128>::{closure#0}
7: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::const_val_to_op
8: rustc_const_eval::const_eval::eval_queries::eval_to_allocation_raw_provider
[... omitted 1 frame ...]
9: <rustc_middle::ty::context::TyCtxt>::const_eval_poly_to_alloc
10: rustc_passes::reachable::reachable_set
[... omitted 1 frame ...]
11: <rustc_metadata::rmeta::encoder::EncodeContext>::encode_crate_root
12: rustc_metadata::rmeta::encoder::encode_metadata::{closure#3}::{closure#0}
13: rustc_metadata::rmeta::encoder::encode_metadata::{closure#3}
14: rustc_metadata::rmeta::encoder::encode_metadata
15: rustc_metadata::fs::encode_and_write_metadata
16: <rustc_interface::queries::Linker>::codegen_and_build_linker
17: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
18: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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 `/Users/timc/foo/rustc-ice-2026-05-23T08_08_40-7937.txt` to your bug report
note: rustc 1.97.0-nightly (7c3c88f42 2026-05-14) running on aarch64-apple-darwin
note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `X`
#1 [reachable_set] reachability
end of query stack
error: could not compile `foo` (lib)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with cargo check --target=i686-unknown-linux-gnu using the src/lib.rs example and src/blank.txt. Then trace the const-evaluation path from rustc_middle/src/mir/interpret/value.rs through eval_to_allocation_raw and metadata encoding. Done means the large string no longer causes an internal compiler error or unsound behavior on the 32-bit target.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 42/100