Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bdcc037

Browse filesBrowse files
legendecasRafaelGSS
authored andcommitted
report: disable js stack when no context is entered
There are no guarantees that the JS stack can be generated when no context is entered. PR-URL: #48495 Fixes: nodejs/node-v8#250 Refs: https://chromium-review.googlesource.com/c/v8/v8/+/4582948 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
1 parent 52de27b commit bdcc037
Copy full SHA for bdcc037

File tree

Expand file treeCollapse file tree

3 files changed

+18
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+18
-12
lines changed
Open diff view settings
Collapse file

‎src/node_report.cc‎

Copy file name to clipboardExpand all lines: src/node_report.cc
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ static void PrintJavaScriptErrorStack(JSONWriter* writer,
6666
Isolate* isolate,
6767
Local<Value> error,
6868
const char* trigger);
69+
static void PrintEmptyJavaScriptStack(JSONWriter* writer);
6970
static void PrintJavaScriptStack(JSONWriter* writer,
7071
Isolate* isolate,
7172
const char* trigger);
@@ -184,6 +185,10 @@ static void WriteNodeReport(Isolate* isolate,
184185

185186
// Report V8 Heap and Garbage Collector information
186187
PrintGCStatistics(&writer, isolate);
188+
} else {
189+
writer.json_objectstart("javascriptStack");
190+
PrintEmptyJavaScriptStack(&writer);
191+
writer.json_objectend(); // the end of 'javascriptStack'
187192
}
188193

189194
// Report native stack backtrace
@@ -452,8 +457,9 @@ static void PrintEmptyJavaScriptStack(JSONWriter* writer) {
452457
static void PrintJavaScriptStack(JSONWriter* writer,
453458
Isolate* isolate,
454459
const char* trigger) {
455-
// Can not capture the stacktrace when the isolate is in a OOM state.
456-
if (!strcmp(trigger, "OOMError")) {
460+
// Can not capture the stacktrace when the isolate is in a OOM state or no
461+
// context is entered.
462+
if (!strcmp(trigger, "OOMError") || !isolate->InContext()) {
457463
PrintEmptyJavaScriptStack(writer);
458464
return;
459465
}
Collapse file

‎test/addons/report-api/test.js‎

Copy file name to clipboardExpand all lines: test/addons/report-api/test.js
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const tmpdir = require('../../common/tmpdir');
99
const binding = path.resolve(__dirname, `./build/${common.buildType}/binding`);
1010
const addon = require(binding);
1111

12-
function myAddonMain(method, { hasIsolate, hasEnv }) {
12+
function myAddonMain(method, { hasContext, hasEnv }) {
1313
tmpdir.refresh();
1414
process.report.directory = tmpdir.path;
1515

@@ -27,10 +27,10 @@ function myAddonMain(method, { hasIsolate, hasEnv }) {
2727
const content = require(report);
2828

2929
// Check that the javascript stack is present.
30-
if (hasIsolate) {
30+
if (hasContext) {
3131
assert.strictEqual(content.javascriptStack.stack.findIndex((frame) => frame.match('myAddonMain')), 0);
3232
} else {
33-
assert.strictEqual(content.javascriptStack, undefined);
33+
assert.strictEqual(content.javascriptStack.message, 'No stack.');
3434
}
3535

3636
if (hasEnv) {
@@ -45,9 +45,9 @@ const methods = [
4545
['triggerReportNoIsolate', false, false],
4646
['triggerReportEnv', true, true],
4747
['triggerReportNoEnv', false, false],
48-
['triggerReportNoContext', true, false],
48+
['triggerReportNoContext', false, false],
4949
['triggerReportNewContext', true, false],
5050
];
51-
for (const [method, hasIsolate, hasEnv] of methods) {
52-
myAddonMain(method, { hasIsolate, hasEnv });
51+
for (const [method, hasContext, hasEnv] of methods) {
52+
myAddonMain(method, { hasContext, hasEnv });
5353
}
Collapse file

‎test/common/report.js‎

Copy file name to clipboardExpand all lines: test/common/report.js
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,19 @@ function validateContent(report, fields = []) {
5555

5656
function _validateContent(report, fields = []) {
5757
const isWindows = process.platform === 'win32';
58-
const isJavaScriptThreadReport = report.javascriptStack != null;
58+
const isJavaScriptThreadReport = report.javascriptHeap != null;
5959

6060
// Verify that all sections are present as own properties of the report.
61-
const sections = ['header', 'nativeStack', 'libuv', 'environmentVariables',
62-
'sharedObjects', 'resourceUsage', 'workers'];
61+
const sections = ['header', 'nativeStack', 'javascriptStack', 'libuv',
62+
'environmentVariables', 'sharedObjects', 'resourceUsage', 'workers'];
6363
if (!isWindows)
6464
sections.push('userLimits');
6565

6666
if (report.uvthreadResourceUsage)
6767
sections.push('uvthreadResourceUsage');
6868

6969
if (isJavaScriptThreadReport)
70-
sections.push('javascriptStack', 'javascriptHeap');
70+
sections.push('javascriptHeap');
7171

7272
checkForUnknownFields(report, sections);
7373
sections.forEach((section) => {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.