Skip to content

alloc_error_handler can be an unsafe fn which is then unsoundly invoked #134225

Open
@RalfJung

Description

This code currently compiles:

#![feature(alloc_error_handler)]
#![no_std]

extern crate alloc;

#[alloc_error_handler]
unsafe fn f(_: alloc::alloc::Layout) -> ! {
    core::hint::unreachable_unchecked();
}

This is unsound if the alloc error handler ever gets invoked.

The alloc_error_handler feature is still unstable, tracking issue: #51540

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions