mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
report: handle on-fatalerror better
--report-on-fatalerror was not honored properly, as there was no way to check the value which was stored in the Environment pointer which can be inaccessible under certain fatal error situations. Move the flag out of Environment pointer so that this is doable. Co-authored-by: Shobhit Chittora schittora@paypal.com PR-URL: https://github.com/nodejs/node/pull/32207 Fixes: https://github.com/nodejs/node/issues/31576 Refs: https://github.com/nodejs/node/pull/29881 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
This commit is contained in:
committed by
Sam Roberts
parent
388cef61e8
commit
2fa74e3e38
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
// Testcase to produce report on fatal error (javascript heap OOM)
|
||||
if (process.argv[2] === 'child') {
|
||||
@@ -20,17 +20,26 @@ if (process.argv[2] === 'child') {
|
||||
const helper = require('../common/report.js');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
const spawn = require('child_process').spawn;
|
||||
const args = ['--report-on-fatalerror',
|
||||
'--max-old-space-size=20',
|
||||
__filename,
|
||||
'child'];
|
||||
const child = spawn(process.execPath, args, { cwd: tmpdir.path });
|
||||
child.on('exit', common.mustCall((code) => {
|
||||
assert.notStrictEqual(code, 0, 'Process exited unexpectedly');
|
||||
const reports = helper.findReports(child.pid, tmpdir.path);
|
||||
assert.strictEqual(reports.length, 1);
|
||||
const report = reports[0];
|
||||
helper.validate(report);
|
||||
}));
|
||||
const spawnSync = require('child_process').spawnSync;
|
||||
let args = ['--report-on-fatalerror',
|
||||
'--max-old-space-size=20',
|
||||
__filename,
|
||||
'child'];
|
||||
|
||||
let child = spawnSync(process.execPath, args, { cwd: tmpdir.path });
|
||||
|
||||
assert.notStrictEqual(child.status, 0, 'Process exited unexpectedly');
|
||||
let reports = helper.findReports(child.pid, tmpdir.path);
|
||||
assert.strictEqual(reports.length, 1);
|
||||
const report = reports[0];
|
||||
helper.validate(report);
|
||||
// Verify that reports are not created on fatal error by default.
|
||||
args = ['--max-old-space-size=20',
|
||||
__filename,
|
||||
'child'];
|
||||
|
||||
child = spawnSync(process.execPath, args, { cwd: tmpdir.path });
|
||||
assert.notStrictEqual(child.status, 0, 'Process exited unexpectedly');
|
||||
reports = helper.findReports(child.pid, tmpdir.path);
|
||||
assert.strictEqual(reports.length, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user