Skip to content

Trying to allocate isize::MAX + 1 bytes ICEs Miri #3679

Closed
@saethlin

Description

@saethlin

This program (reduced from an ICE encountered when running the tests for https://crates.io/crates/tinyset):

fn main() {
    let bytes = isize::MAX as usize + 1;
    unsafe {
        let layout = std::alloc::Layout::from_size_align_unchecked(bytes, 1); // Undetected library(?) UB here
        let _ = std::alloc::alloc_zeroed(layout);
    }
}

Hits this ICE:

thread 'rustc' panicked at src/tools/miri/src/alloc_bytes.rs:71:59:
called `Result::unwrap()` on an `Err` value: LayoutError

Caused by this unwrap:

let layout = Layout::from_size_align(size, align).unwrap();

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEImpact: makes Miri crash with some ICE

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions