Skip to content

fix: don't allocate crash keys inside the v8 oom callback - #52724

Merged
MarshallOfSound merged 6 commits into
44-x-yfrom
trop/44-x-y-bp-fix-don-t-allocate-crash-keys-inside-the-v8-oom-callback-1786244716728
Aug 9, 2026
Merged

MarshallOfSound merged 6 commits into
44-x-yfrom
trop/44-x-y-bp-fix-don-t-allocate-crash-keys-inside-the-v8-oom-callback-1786244716728

Conversation

@trop

@trop trop Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Backport of #52591

See that PR for details.

Notes: Fixed an issue where a JavaScript out-of-memory crash could be reported from inside the crash-key handler instead of at the out-of-memory site.

trop Bot and others added 6 commits August 9, 2026 03:05
V8OOMErrorCallback records five electron.v8-oom.* crash keys through
electron::crash_keys::SetCrashKey, which grows two std::deques and
builds std::strings - allocation inside V8's out-of-memory handler,
which can also fire on a V8 worker thread. In crash reports this shows
up as the process dying inside SetCrashKey instead of at OOM_CRASH(),
losing the OOM signature the keys were meant to record.

Use statically registered fixed-storage crash_reporter::CrashKeyStrings
and format the heap stats into a stack buffer with
base::strings::SafeSPrintf, so nothing on the OOM path allocates.

Co-authored-by: Shelley Vohr <[email protected]>
V8OOMErrorCallback recorded its electron.v8-oom.* keys through
electron::crash_keys::SetCrashKey, whose registry grows two std::deques
and is written from whichever thread reports the OOM, so a V8 worker
thread races the main thread inside SetCrashKey. The renderer's
near-heap-limit callback writes the same key names through the same
registry from every isolate that registers it, so the race is
cross-thread even without the OOM callback, and fixed keys added only to
the OOM path would duplicate its annotations.

Give the whole electron.v8-oom.* set one owner (statically registered
crash_reporter::CrashKeyString storage in shell/common/v8_oom_diagnostics)
shared by both callbacks, with an atomic first claim: the first isolate
to hit an OOM records its diagnostics and later isolates return without
writing, so concurrent OOMs cannot interleave and worker diagnostics are
kept. The SetCrashKey path is removed from both call sites.

Co-authored-by: Shelley Vohr <[email protected]>
Co-authored-by: Shelley Vohr <[email protected]>
Co-authored-by: Shelley Vohr <[email protected]>
@trop
trop Bot requested a review from codebytere August 9, 2026 03:06
@trop trop Bot added 44-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels Aug 9, 2026
@MarshallOfSound
MarshallOfSound enabled auto-merge (squash) August 9, 2026 08:15
@MarshallOfSound
MarshallOfSound merged commit 46daf63 into 44-x-y Aug 9, 2026
138 of 140 checks passed
@MarshallOfSound
MarshallOfSound deleted the trop/44-x-y-bp-fix-don-t-allocate-crash-keys-inside-the-v8-oom-callback-1786244716728 branch August 9, 2026 08:31
@release-clerk

release-clerk Bot commented Aug 9, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed an issue where a JavaScript out-of-memory crash could be reported from inside the crash-key handler instead of at the out-of-memory site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

44-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes

Projects

No open projects
Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant