-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
report: print javascript stack on fatal error
Try to print JavaScript stack on fatal error. OOMError needs to be distinguished from fatal error since no new handle can be created at that time. PR-URL: #44242 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
- Loading branch information
1 parent
f3fd4e1
commit 53364fc
Showing
8 changed files
with
196 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <node.h> | ||
#include <v8.h> | ||
|
||
using v8::FunctionCallbackInfo; | ||
using v8::Isolate; | ||
using v8::Local; | ||
using v8::MaybeLocal; | ||
using v8::Object; | ||
using v8::Value; | ||
|
||
void TriggerFatalError(const FunctionCallbackInfo<Value>& args) { | ||
Isolate* isolate = args.GetIsolate(); | ||
|
||
// Trigger a v8 ApiCheck failure. | ||
MaybeLocal<Value> value; | ||
value.ToLocalChecked(); | ||
} | ||
|
||
void init(Local<Object> exports) { | ||
NODE_SET_METHOD(exports, "triggerFatalError", TriggerFatalError); | ||
} | ||
|
||
NODE_MODULE(NODE_GYP_MODULE_NAME, init) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
'targets': [ | ||
{ | ||
'target_name': 'binding', | ||
'sources': [ 'binding.cc' ], | ||
'includes': ['../common.gypi'], | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
'use strict'; | ||
|
||
const common = require('../../common'); | ||
const assert = require('assert'); | ||
const path = require('path'); | ||
const spawnSync = require('child_process').spawnSync; | ||
const helper = require('../../common/report.js'); | ||
const tmpdir = require('../../common/tmpdir'); | ||
|
||
const binding = path.resolve(__dirname, `./build/${common.buildType}/binding`); | ||
|
||
if (process.argv[2] === 'child') { | ||
(function childMain() { | ||
const addon = require(binding); | ||
addon.triggerFatalError(); | ||
})(); | ||
return; | ||
} | ||
|
||
const ARGS = [ | ||
__filename, | ||
'child', | ||
]; | ||
|
||
{ | ||
// Verify that --report-on-fatalerror is respected when set. | ||
tmpdir.refresh(); | ||
const args = ['--report-on-fatalerror', ...ARGS]; | ||
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path }); | ||
assert.notStrictEqual(child.status, 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 content = require(report); | ||
assert.strictEqual(content.header.trigger, 'FatalError'); | ||
|
||
// Check that the javascript stack is present. | ||
assert.strictEqual(content.javascriptStack.stack.findIndex((frame) => frame.match('childMain')), 0); | ||
} | ||
|
||
{ | ||
// Verify that --report-on-fatalerror is respected when not set. | ||
const args = ARGS; | ||
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path }); | ||
assert.notStrictEqual(child.status, 0, 'Process exited unexpectedly'); | ||
const reports = helper.findReports(child.pid, tmpdir.path); | ||
assert.strictEqual(reports.length, 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters