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 a1d7ed7

Browse filesBrowse files
addaleaxMylesBorins
authored andcommitted
tracing: fix static destruction order issue
Sometimes, the `parallel/test-tracing-no-crash` would not work as expected, at least on Windows, because there is a static destruction race between tearing down the `NodeTraceWriter` instance and the per-process options struct. If the per-process options were destroyed before the `NodeTraceWriter`, the reference to the tracing filename would be gone before opening the file was attempted. This can be solved by creating a copy of the string when creating the `NodeTraceWriter` instance rather than taking a reference. Fixes: #22523 PR-URL: #24123 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent abe3eda commit a1d7ed7
Copy full SHA for a1d7ed7

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

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

‎src/tracing/node_trace_writer.h‎

Copy file name to clipboardExpand all lines: src/tracing/node_trace_writer.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class NodeTraceWriter : public AsyncTraceWriter {
6161
int highest_request_id_completed_ = 0;
6262
int total_traces_ = 0;
6363
int file_num_ = 0;
64-
const std::string& log_file_pattern_;
64+
std::string log_file_pattern_;
6565
std::ostringstream stream_;
6666
std::unique_ptr<TraceWriter> json_trace_writer_;
6767
bool exited_ = false;
Collapse file

‎test/parallel/test-tracing-no-crash.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-tracing-no-crash.js
+11-3Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ function CheckNoSignalAndErrorCodeOne(code, signal) {
88
assert.strictEqual(code, 1);
99
}
1010

11-
const child = spawn(process.execPath,
12-
['--trace-event-categories', 'madeup', '-e',
13-
'throw new Error()'], { stdio: 'inherit' });
11+
const child = spawn(process.execPath, [
12+
'--trace-event-categories', 'madeup', '-e', 'throw new Error()'
13+
], { stdio: [ 'inherit', 'inherit', 'pipe' ] });
1414
child.on('exit', common.mustCall(CheckNoSignalAndErrorCodeOne));
15+
16+
let stderr;
17+
child.stderr.setEncoding('utf8');
18+
child.stderr.on('data', (chunk) => stderr += chunk);
19+
child.stderr.on('end', common.mustCall(() => {
20+
assert(stderr.includes('throw new Error()'), stderr);
21+
assert(!stderr.includes('Could not open trace file'), stderr);
22+
}));

0 commit comments

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