Skip to content

array types (fixed-size arrays on 32-bit, HashMap, Vec) can be large enough that indexing is unsound #18726

Closed
@thestinger

Description

@thestinger

In a 32-bit process running on a 64-bit operating system, it's possible to allocate a Vec<u8> of length 1u32 << 31 or greater. The maximum value where uint as int produces a positive number is (1u32 << 31) - 1), so int is not large enough for offset operations to the end of these vectors. Everything from the language's built-in slice indexing operations to the push method on Vec<T> will perform an invalid negative (backwards) offset as the getelementptr instruction uses a signed offset.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-collectionsArea: `std::collections`A-type-systemArea: Type systemI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.P-mediumMedium priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions