diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-11-06 10:21:43 +0000 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-11-10 12:07:43 +0100 |
commit | 71a4cb7d460abb50ef6816917dfc290c4312f00f (patch) | |
tree | ee1fe909c32e2e744d57c8c9973f7433528c9979 /src | |
parent | f8c3e258fdaf2961425455e09a19c7dd3ed3fa05 (diff) | |
download | node-new-71a4cb7d460abb50ef6816917dfc290c4312f00f.tar.gz |
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: https://github.com/nodejs/node/issues/22523
PR-URL: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'src')
-rw-r--r-- | src/tracing/node_trace_writer.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/tracing/node_trace_writer.h b/src/tracing/node_trace_writer.h index 5e5781479c..a91176ad49 100644 --- a/src/tracing/node_trace_writer.h +++ b/src/tracing/node_trace_writer.h @@ -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_; std::ostringstream stream_; std::unique_ptr<TraceWriter> json_trace_writer_; bool exited_ = false; |