Skip to content

const heap: fix ICE on forgotten make_global #144024

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

Closed
wants to merge 5 commits into from

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Jul 16, 2025

This fixes the ICE in code like this:

const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32 };

To do this I unified the error handling for missing make_global with the existing interning error handling, which wasn't half as bad as we though it'd be in #143595.

This is based on #143595; only the last two commits are new.

  • The first one implements the behavior change.
  • The second is just refactoring, simplifying things so we can get rid of a single-use trait.

Cc @fee1-dead

Fixes #129233

fee1-dead and others added 3 commits July 16, 2025 00:32
Co-Authored-By: Ralf Jung <post@ralfj.de>
Co-Authored-By: Oli Scherer <github333195615777966@oli-obk.de>
Co-Authored-By: Ralf Jung <post@ralfj.de>
@rustbot
Copy link
Collaborator

rustbot commented Jul 16, 2025

r? @oli-obk

rustbot has assigned @oli-obk.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 16, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 16, 2025

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

@fee1-dead
Copy link
Member

fee1-dead commented Jul 16, 2025

tests/crashes/const_mut_ref_check_bypass.rs needs to be removed, also add "Fixes #129233" in the PR description

I'd r+ it but my PR is in queue. I can also cherry pick these commits and make it r=RalfJung,fee1-dead on my PR

@rustbot
Copy link
Collaborator

rustbot commented Jul 16, 2025

This PR changes a file inside tests/crashes. If a crash was fixed, please move into the corresponding ui subdir and add 'Fixes #' to the PR description to autoclose the issue upon merge.

@RalfJung
Copy link
Member Author

I can also cherry pick these commits and make it r=RalfJung,fee1-dead on my PR

Okay, let's do that. :)

@RalfJung
Copy link
Member Author

Closing in favor of #143595.

@RalfJung RalfJung closed this Jul 16, 2025
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 16, 2025
@RalfJung RalfJung deleted the make-global-ice branch July 17, 2025 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

const_heap feature can be used to leak mutable memory into final value of constant
4 participants