rust-lang / rust-lang/rust

Large const allocations no longer lead to graceful errors on aarch64

Open
#135,952 16 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug P-medium regression-from-stable-to-stable T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I just spun up an aarch64 (c6g.metal) instance to look at codegen, and I noticed that two of our UI tests do not pass:

    [ui] tests/ui/consts/large_const_alloc.rs
    [ui] tests/ui/consts/promoted_running_out_of_memory_issue-130687.rs

I can reduce one of the failing tests to this:

#![crate_type = "lib"]
pub const FOO: &[u8] = &[0_u8; (1 << 47) - 1];

If I am on an x86_64 host targeting aarch64-unknown-linux-gnu, using stable or nightly, this will immediately fail to compile with:

error[E0080]: evaluation of constant value failed
 --> demo.rs:2:25
  |
2 | pub const FOO: &[u8] = &[0_u8; (1 << 47) - 1];
  |                         ^^^^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler

error: aborting due to 1 previous error

If my host is aarch64-unknown-linux-gnu using stable, I also get that diagnostic. But nightly toolchains on an aarch64 host allocate more and more memory, eventually dying with SIGKILL.

Bisection points to https://github.com/rust-lang/rust/pull/135262 as the cause, which suggests that this is a miscompile.

searched nightlies: from nightly-2024-01-01 to nightly-2025-01-23
regressed nightly: nightly-2025-01-13
searched commit range: https://github.com/rust-lang/rust/compare/eb54a50837ad4bcc9842924f27e7287ca66e294c...48a426eca9df23b24b3559e545cf88dee61d4de9
regressed commit: https://github.com/rust-lang/rust/commit/c0f6a1ce3f89a3240efe5c83839675e20f84e001

bisected with cargo-bisect-rustc v0.6.9

Host triple: aarch64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --script script.sh --start 2024-01-01 

This is worth further investigation. Of course it is plausible that a change to the CI configuration would alter the build artifacts from CI, but bisecting a test failure from a stage1 and stage2 toolchain to a CI change is odd.

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.

Research direction

Start with tests/ui/consts/large_const_alloc.rs and tests/ui/consts/promoted_running_out_of_memory_issue-130687.rs, reproducing the reduced constant on aarch64-unknown-linux-gnu. Read PR #135262 and compare the behavior around the regressed nightly range and commit c0f6a1ce; done means both UI tests fail gracefully rather than exhausting memory or being killed on an aarch64 host.

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
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.