Skip to content

Large allocations in const eval can OOM crash the compiler #79601

Closed
@oli-obk

Description

@oli-obk

I tried this code:

const FOO: () = {
    let x = [0_u8; 1000*1000*1000];  
};

I expected to see this happen: An error about the constant evaluation using more memory than the compiler having available

Instead, this happened: The compiler triggered an abort

Meta

rustc --version --verbose:

1.48.0
Backtrace

I think we'll need to stop using Vec and move to manually using AllocRef::alloc (and maybe Box<[u8]>? in order to allow bubbling up allocation errors during const eval back to the user via error messages.

cc @rust-lang/wg-const-eval

related: #23600

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions