mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
7752eedcc7
The OOM test uses a value that caused an OOM crash from V8 on certain machines when V8 did not notify the host of OOM soon enough. PR-URL: https://github.com/nodejs/node/pull/41681 Refs: https://github.com/tc39/proposal-iterator-helpers#asindexedpairs Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
29 lines
1.0 KiB
JavaScript
29 lines
1.0 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
|
|
// This test ensures that an out of memory error exits with code 134 on Windows
|
|
|
|
if (!common.isWindows) return common.skip('Windows-only');
|
|
|
|
const assert = require('assert');
|
|
const { exec } = require('child_process');
|
|
|
|
if (process.argv[2] === 'heapBomb') {
|
|
// Heap bomb, imitates a memory leak quickly
|
|
const fn = (nM) => [...Array(nM)].map((i) => fn(nM * 2));
|
|
fn(2);
|
|
}
|
|
|
|
// Run child in tmpdir to avoid report files in repo
|
|
const tmpdir = require('../common/tmpdir');
|
|
tmpdir.refresh();
|
|
|
|
// --max-old-space-size=3 is the min 'old space' in V8, explodes fast
|
|
const cmd = `"${process.execPath}" --max-old-space-size=30 "${__filename}"`;
|
|
exec(`${cmd} heapBomb`, { cwd: tmpdir.path }, common.mustCall((err, stdout, stderr) => {
|
|
const msg = `Wrong exit code of ${err.code}! Expected 134 for abort`;
|
|
// Note: common.nodeProcessAborted() is not asserted here because it
|
|
// returns true on 134 as well as 0x80000003 (V8's base::OS::Abort)
|
|
assert.strictEqual(err.code, 134, msg);
|
|
}));
|