[ICE]: llvm assertion with debuginfo `Assertion SizeInBits >= OffsetInBits - FragmentOffset && "size underflow" failed`
Open
Nobody has claimed this yet.
A-debuginfo
A-LLVM
A-LTO
C-bug
I-crash
needs-triage
requires-debug-assertions
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
reduced from #116541 , can crash llvm at compiletime
Code
flags: -Cdebuginfo=2 -Copt-level=3 -Clto -Clink-dead-code=true --crate-type=lib
const SIZE: usize = 1024 * 1024 * 1024;
struct Outer {
a: LargeStruct,
}
impl Outer {
fn new() -> Self {
let a = LargeStruct::new();
Self { a }
}
}
struct LargeStruct {
d4: Option<Box<u128>>,
huge: [u8; SIZE],
}
impl LargeStruct {
fn new() -> Self {
Self {
d4: None,
huge: [0; SIZE],
}
}
}
Meta
rustc --version --verbose:
rustc 1.97.0-nightly (f53b654a8 2026-04-30)
binary: rustc
commit-hash: f53b654a8882fd5fc036c4ca7a4ff41ce32497a6
commit-date: 2026-04-30
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.4
Error output
<output>
Backtrace
warning: constant `SIZE` is never used
--> code.rs:1:7
|
1 | const SIZE: usize = 1024 * 1024 * 1024;
| ^^^^
|
= note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default
warning: struct `Outer` is never constructed
--> code.rs:2:8
|
2 | struct Outer {
| ^^^^^
warning: associated function `new` is never used
--> code.rs:6:8
|
5 | impl Outer {
| ---------- associated function in this implementation
6 | fn new() -> Self {
| ^^^
warning: struct `LargeStruct` is never constructed
--> code.rs:11:8
|
11 | struct LargeStruct {
| ^^^^^^^^^^^
warning: associated function `new` is never used
--> code.rs:16:8
|
15 | impl LargeStruct {
| ---------------- associated function in this implementation
16 | fn new() -> Self {
| ^^^
rustc: /checkout/src/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp:542: bool llvm::DwarfExpression::addExpression(DIExpressionCursor &&, llvm::function_ref<bool (unsigned int, DIExpressionCursor &)>): Assertion `SizeInBits >= OffsetInBits - FragmentOffset && "size underflow"' failed.
[1] 1880730 IOT instruction ~/.rustup/toolchains/alt-master/bin/rustc -Cdebuginfo=2 -Copt-level=3 -Clto
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 crash from the issue's Rust example with -Cdebuginfo=2, -Copt-level=3, -Clto, and -Clink-dead-code=true. Start at llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp:542 and investigate the reported debug-info assertion. Done means the minimized example no longer triggers the LLVM assertion while preserving the relevant compilation behavior.
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
- Mostly clear
- Newbie friendliness
- 48/100