Skip to content

Removing allocations is technically unsound in OOM (out-of-memory) situations #328

Open
@RalfJung

Description

@RalfJung

The following program might be considered to be guaranteed to run out of memory, but LLVM actually compiles it in a way that it does not:

int *x = malloc(SIZE_MAX);
int *y = malloc(SIZE_MAX);
if (x && y) {
  printf("This is unreachable. I could deref a NULL pointer and this program would still be fine.");
}

It is not clear how to formally justify this.

@JakobDegen also has an example for recursion exhausting memory via stack allocations and being similarly optimized away.

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