From 4c7fdc2deb87594f95c2272c336dd137318ffad7 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Fri, 11 Sep 2026 09:22:09 +0200 Subject: [PATCH 1/4] test: avoid allocations in external memory test Inspect the parsed V8 flags instead of allocating over a gigabyte and aborting child processes. This avoids memory pressure and core dumps in test-external-memory-reasonable-size. Also verify that Node disables the limit by default. Refs: https://github.com/nodejs/node/pull/65780 Signed-off-by: Filip Skokan Assisted-by: Codex --- .../test-external-memory-reasonable-size.js | 40 ++++++------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/test/parallel/test-external-memory-reasonable-size.js b/test/parallel/test-external-memory-reasonable-size.js index f9ff1af8e5a1..0fa585e8742f 100644 --- a/test/parallel/test-external-memory-reasonable-size.js +++ b/test/parallel/test-external-memory-reasonable-size.js @@ -1,34 +1,20 @@ 'use strict'; -// V8 aborts the process when external memory grows by more than -// --external-memory-max-reasonable-size gigabytes in a single step. Node -// disables that check by default, but an explicit value on the command line -// must still be honored. +// Node disables V8's external memory reasonable size check by default, but +// explicit values on the command line must still be honored. // Refs: https://github.com/nodejs/node/issues/65534 -const common = require('../common'); -const assert = require('assert'); -const { execSync } = require('child_process'); -const { totalmem } = require('os'); +require('../common'); +const { spawnSyncAndAssert } = require('../common/child_process'); -// The smallest limit V8 accepts is 1 GB, so the child has to allocate more -// than that before the check can fire. -if (totalmem() < 4 * 1024 ** 3) - common.skip('not enough memory to exceed a 1 GB external memory limit'); - -for (const flag of [ - '--external-memory-max-reasonable-size=1', - '--external_memory_max_reasonable_size=1', +// Despite the "default" label, --v8-options prints the parsed flag values. +// Inspect them without allocating over a gigabyte and crashing the child. +for (const [flags, expected] of [ + [[], 0], + [['--external-memory-max-reasonable-size=1'], 1], + [['--external_memory_max_reasonable_size=1'], 1], ]) { - // The child aborts with over a gigabyte resident, so keep it from writing a - // core file; on some hosts that dump alone outlasts the test timeout. - const [cmd, opts] = common.escapePOSIXShell`"${process.execPath}" ${flag} -e "new Float64Array(150_000_000)"`; - assert.throws( - () => execSync(common.isWindows ? cmd : `ulimit -c 0; ${cmd}`, { ...opts, stdio: 'pipe' }), - (err) => { - assert.notStrictEqual(err.status, 0, `${flag} was not honored, the child exited cleanly`); - assert.match(err.stderr.toString(), /kMaxReasonableBytes/); - return true; - }, - ); + spawnSyncAndAssert(process.execPath, [...flags, '--v8-options'], { + stdout: new RegExp(`default: --external-memory-max-reasonable-size=${expected}\\r?$`, 'm'), + }); } From a4380b1fb57f4596000554c370fb3e07c10aee05 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Fri, 11 Sep 2026 12:28:03 +0200 Subject: [PATCH 2/4] Update test/parallel/test-external-memory-reasonable-size.js Co-authored-by: Antoine du Hamel --- test/parallel/test-external-memory-reasonable-size.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-external-memory-reasonable-size.js b/test/parallel/test-external-memory-reasonable-size.js index 0fa585e8742f..17e675fe814f 100644 --- a/test/parallel/test-external-memory-reasonable-size.js +++ b/test/parallel/test-external-memory-reasonable-size.js @@ -1,6 +1,6 @@ 'use strict'; -// Node disables V8's external memory reasonable size check by default, but +// Node.js disables V8's external memory reasonable size check by default, but // explicit values on the command line must still be honored. // Refs: https://github.com/nodejs/node/issues/65534 From 3925925442edb9cf17bf583e71d2d9ea4397a21d Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Fri, 11 Sep 2026 12:35:45 +0200 Subject: [PATCH 3/4] Update test/parallel/test-external-memory-reasonable-size.js Co-authored-by: Antoine du Hamel --- test/parallel/test-external-memory-reasonable-size.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-external-memory-reasonable-size.js b/test/parallel/test-external-memory-reasonable-size.js index 17e675fe814f..06ecbc18d7a4 100644 --- a/test/parallel/test-external-memory-reasonable-size.js +++ b/test/parallel/test-external-memory-reasonable-size.js @@ -15,6 +15,6 @@ for (const [flags, expected] of [ [['--external_memory_max_reasonable_size=1'], 1], ]) { spawnSyncAndAssert(process.execPath, [...flags, '--v8-options'], { - stdout: new RegExp(`default: --external-memory-max-reasonable-size=${expected}\\r?$`, 'm'), + stdout: new RegExp(`default: --external-memory-max-reasonable-size=${expected}$`, 'm'), }); } From 61f9ca6bfa99421f1b7d650a5e7a675631934b33 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Fri, 11 Sep 2026 14:08:49 +0200 Subject: [PATCH 4/4] Update test/parallel/test-external-memory-reasonable-size.js Co-authored-by: Antoine du Hamel --- test/parallel/test-external-memory-reasonable-size.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/parallel/test-external-memory-reasonable-size.js b/test/parallel/test-external-memory-reasonable-size.js index 06ecbc18d7a4..2d79eec892c1 100644 --- a/test/parallel/test-external-memory-reasonable-size.js +++ b/test/parallel/test-external-memory-reasonable-size.js @@ -8,7 +8,6 @@ require('../common'); const { spawnSyncAndAssert } = require('../common/child_process'); // Despite the "default" label, --v8-options prints the parsed flag values. -// Inspect them without allocating over a gigabyte and crashing the child. for (const [flags, expected] of [ [[], 0], [['--external-memory-max-reasonable-size=1'], 1],