rust-lang / rust-lang/rust

GVN can cause OOM

Open
#153,626 2 comments 0 reactions 1 assignee View on GitHub

@cjgillot is already working on this.

Since Jun 14, 2026.

A-mir-opt-GVN C-bug I-compilemem I-crash T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

//@compile-flags: -Zmir-opt-level=5
use std::mem::MaybeUninit;

const N: usize = 0x0000_7ff0_0000_0000;

pub fn g(n: &u8) {
    let mut xs = MaybeUninit::<[u8; N]>::uninit();
}

pub fn main() {
    let n = Box::new(27);
    g(&n);
}

Originally reported as an ICE in https://github.com/rust-lang/rust/issues/149643. We no longer ICE, we now exit with a "proper" OOM error, but rustc still quits.

I'm surprised GVN does not have some kind of cap to ensure it doesn't consume excessive amounts of memory?
Cc @rust-lang/wg-mir-opt @cjgillot @saethlin

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.