Skip to content

src: disable V8 external memory reasonable size check - #65589

Open
bitpshr wants to merge 1 commit into
nodejs:mainfrom
bitpshr:v8/external-memory-check
Open

src: disable V8 external memory reasonable size check#65589
bitpshr wants to merge 1 commit into
nodejs:mainfrom
bitpshr:v8/external-memory-check

Conversation

@bitpshr

@bitpshr bitpshr commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Fixes: #65534

V8 aborts the process when external memory grows by more than --external-memory-max-reasonable-size gigabytes in a single step, which defaults to 32. Allocating a buffer larger than that is a legitimate thing to do in Node, and it should raise a RangeError rather than terminate the process:

# Fatal error in , line 0
# Check failed: change_in_bytes < kMaxReasonableBytes.

This defaults the flag to 0 unless the user supplied a value, next to the other V8 defaults Node already sets explicitly. Per @Renegade334 on the issue, the 32 GB limit is a Chromium oriented sanity check rather than something Node wants to inherit.

The guard checks both the dashed and underscored spellings, since V8 accepts either, and appends only when neither is present so an explicit --external-memory-max-reasonable-size=N still wins.

On testing: reproducing the real thing needs more than 32 GB of RAM, which I do not have, so I verified against a lowered threshold instead. --external-memory-max-reasonable-size=1 plus a 2 GB allocation produces the identical fatal check, and the same allocation succeeds once the flag defaults to 0. The test covers the override path rather than the new default, because asserting the default is gone would need a >32 GB allocation in CI. I confirmed the test fails if the appended flag clobbers a user supplied value, so it does catch the case it is there for.

V8 aborts the process when external memory grows by more than
--external-memory-max-reasonable-size gigabytes in a single step. The
32 GB default is a Chromium-oriented sanity check; allocating a buffer
larger than that is legitimate in Node and should raise a RangeError
rather than terminate the process.

Default the flag to 0 unless the user supplied a value, alongside the
other V8 defaults Node sets explicitly.

Fixes: nodejs#65534
Signed-off-by: Paul Bouchon <mail@bitpshr.net>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/startup

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

crash when trying to create large arrays (32 GB+) due to V8's check for kMaxReasonableBytes

2 participants