Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tracing: fix static destruction order issue #24123

Closed

Conversation

addaleax
Copy link
Member

@addaleax addaleax commented Nov 6, 2018

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

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes (presumably)
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

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: nodejs#22523
@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Nov 6, 2018
@addaleax addaleax added the trace_events Issues and PRs related to V8, Node.js core, and userspace code trace events. label Nov 6, 2018
@@ -61,7 +61,7 @@ class NodeTraceWriter : public AsyncTraceWriter {
int highest_request_id_completed_ = 0;
int total_traces_ = 0;
int file_num_ = 0;
const std::string& log_file_pattern_;
std::string log_file_pattern_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
I've also hit that bug in 6c24c3b

@addaleax
Copy link
Member Author

addaleax commented Nov 6, 2018

@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Nov 6, 2018
@Trott
Copy link
Member

Trott commented Nov 8, 2018

@refack
Copy link
Contributor

refack commented Nov 9, 2018

@Trott
Copy link
Member

Trott commented Nov 9, 2018

@Trott
Copy link
Member

Trott commented Nov 10, 2018

@addaleax
Copy link
Member Author

Landed in 71a4cb7 (thanks everyone for kicking off the CI runs!)

@addaleax addaleax closed this Nov 10, 2018
@addaleax addaleax deleted the tracing-static-destruction-order branch November 10, 2018 11:43
addaleax added a commit that referenced this pull request Nov 10, 2018
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>
BridgeAR pushed a commit that referenced this pull request Nov 14, 2018
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>
kiyomizumia pushed a commit to kiyomizumia/node that referenced this pull request Nov 15, 2018
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: nodejs#22523

PR-URL: nodejs#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>
codebytere pushed a commit that referenced this pull request Dec 14, 2018
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>
MylesBorins pushed a commit that referenced this pull request Dec 26, 2018
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. trace_events Issues and PRs related to V8, Node.js core, and userspace code trace events.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test: flaky test/parallel/test-tracing-no-crash
7 participants