Skip to content

Unchecked memory allocations #30177

@WarrenWeckesser

Description

@WarrenWeckesser

In almost all cases, if a memory allocation in our C & C++ code fails, the failure is handled so that eventually a MemoryError exception is raised by Python. I think that is a general rule that we apply to all low-level code: failure to allocate memory should ultimately result in a Python exception and not crash the interpreter.

Here are a few places where we don't check for a memory allocation failure:

The following uses of std::unordered_set in unique.cpp can throw an exception if an allocation fails, which will crash Python:

(This was not an exhaustive search.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions