Skip to content

Commit f87a265

Browse files
rmacnak-googleCommit Queue
authored andcommitted
[io] Fix data race in Mac file watcher.
TEST=tsan Bug: #61474 Change-Id: I15596b01fab51a8e420aea1dc41868f22785c019 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449061 Commit-Queue: Ryan Macnak <[email protected]> Reviewed-by: Brian Quinlan <[email protected]>
1 parent 2c0648d commit f87a265

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

runtime/bin/file_system_watcher_macos.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class FSEventsWatcher {
132132
DISALLOW_COPY_AND_ASSIGN(Node);
133133
};
134134

135-
FSEventsWatcher() : run_loop_(0) { Start(); }
135+
FSEventsWatcher() : monitor_(), run_loop_(nullptr), owner_() { Start(); }
136136

137137
void Start() {
138138
Thread::Start("dart:io FileWatcher", Run, reinterpret_cast<uword>(this));
@@ -147,11 +147,12 @@ class FSEventsWatcher {
147147
FSEventsWatcher* watcher = reinterpret_cast<FSEventsWatcher*>(arg);
148148
// Only checked in debug mode.
149149
watcher->owner_.Acquire();
150-
watcher->run_loop_ = CFRunLoopGetCurrent();
151-
CFRetain(watcher->run_loop_);
150+
CFRunLoopRef loop = CFRunLoopGetCurrent();
151+
CFRetain(loop);
152152

153153
// Notify, as the run-loop is set.
154154
watcher->monitor().Enter();
155+
watcher->run_loop_ = loop;
155156
watcher->monitor().Notify();
156157
watcher->monitor().Exit();
157158

0 commit comments

Comments
 (0)