apple / apple/foundationdb

Avoid allocating memory in platform::outOfMemory()

Open
#2,834 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
16.7k
Forks
1.6k
Avg merge
1d 20h
Merged PRs (30d)
126

Description

When OOM happens, [this function](
https://github.com/apple/foundationdb/blob/8d655d7e40db9b0e7f93d4b3c46ef86364a537a4/flow/Platform.cpp#L2420) is invoked to write to `stderr` and to write a trace event. However, the trace event itself will also try allocate memory, which again failed. This loops until the stack is overflow, and the stack trace contains repeated frames from `outOfMemory` to `TraceEvent`.

We should fix `platform::outOfMemory()` to avoid allocating memory inside it.

Contributor guide

Open the contributing guide

Research direction

Start by reading flow/Platform.cpp at platform::outOfMemory() and the TraceEvent path it invokes; confirm where allocations occur during OOM. Done means the OOM path can write to stderr and record its trace event without allocating or recursively re-entering after allocation failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.