diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-01-21 22:16:23 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-01-27 20:43:46 +0100 |
commit | 06da364be2d576e9d225ba13d803ebbc0284cfb9 (patch) | |
tree | 79d35cf2fc2305edf94ee1da8b20d37c167337a1 /src/tracing/node_trace_writer.h | |
parent | accd674c9a8445c934bfd4f93151fc840e72414d (diff) | |
download | android-node-v8-06da364be2d576e9d225ba13d803ebbc0284cfb9.tar.gz android-node-v8-06da364be2d576e9d225ba13d803ebbc0284cfb9.tar.bz2 android-node-v8-06da364be2d576e9d225ba13d803ebbc0284cfb9.zip |
src: avoid race condition in tracing code
`json_trace_writer_` is protected by `stream_mutex_`,
but one access to it was not guarded by a lock on said mutex.
Refs: https://github.com/nodejs/node/issues/25512
PR-URL: https://github.com/nodejs/node/pull/25624
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Diffstat (limited to 'src/tracing/node_trace_writer.h')
-rw-r--r-- | src/tracing/node_trace_writer.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/tracing/node_trace_writer.h b/src/tracing/node_trace_writer.h index a91176ad49..f412587ab9 100644 --- a/src/tracing/node_trace_writer.h +++ b/src/tracing/node_trace_writer.h @@ -45,9 +45,11 @@ class NodeTraceWriter : public AsyncTraceWriter { // Triggers callback to close async objects, ending the tracing thread. uv_async_t exit_signal_; // Prevents concurrent R/W on state related to serialized trace data - // before it's written to disk, namely stream_ and total_traces_. + // before it's written to disk, namely stream_ and total_traces_ + // as well as json_trace_writer_. Mutex stream_mutex_; // Prevents concurrent R/W on state related to write requests. + // If both mutexes are locked, request_mutex_ has to be locked first. Mutex request_mutex_; // Allows blocking calls to Flush() to wait on a condition for // trace events to be written to disk. |