This repository was archived by the owner on Jun 18, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathtest-fatal-error.js
More file actions
43 lines (39 loc) · 1.32 KB
/
test-fatal-error.js
File metadata and controls
43 lines (39 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'use strict';
// Testcase to produce report on fatal error (javascript heap OOM)
if (process.argv[2] === 'child') {
require('../');
const list = [];
// tap with coverage enabled installs signal handlers that prevents the
// fatal error causing the process to exit. Remove them.
process.removeAllListeners('SIGABRT');
process.removeAllListeners('SIGTRAP');
while (true) {
const record = new MyRecord();
list.push(record);
}
function MyRecord() {
this.name = 'foo';
this.id = 128;
this.account = 98454324;
}
} else {
const common = require('./common.js');
const spawn = require('child_process').spawn;
const tap = require('tap');
const args = ['--max-old-space-size=20', __filename, 'child'];
const child = spawn(process.execPath, args);
child.on('exit', (code) => {
tap.plan(3);
tap.notEqual(code, 0, 'Process should not exit cleanly');
const reports = common.findReports(child.pid);
tap.equal(reports.length, 1, 'Found reports ' + reports);
const report = reports[0];
const options = {pid: child.pid};
// Node.js currently overwrites the command line on AIX
// https://github.com/nodejs/node/issues/10607
if (!(common.isAIX() || common.isSunOS())) {
options.commandline = child.spawnargs.join(' ');
}
common.validate(tap, report, options);
});
}