Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3410)

Unified Diff: base/threading/thread.h

Issue 2303943003: Ensure that |Thread::id_| is only accessed when an happens-after relationship has been established … (Closed)
Patch Set: Only AssertWaitAllowed() in WaitableEvent::TimedWait if time is non-zero Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/synchronization/waitable_event_win.cc ('k') | base/threading/thread.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/thread.h
diff --git a/base/threading/thread.h b/base/threading/thread.h
index 61445d12f95f22a8865e8dbfe385a6ddcac67a64..5bb53f77d3086faf64f8c109d0b2ec1a3bdfc52d 100644
--- a/base/threading/thread.h
+++ b/base/threading/thread.h
@@ -189,8 +189,8 @@ class BASE_EXPORT Thread : PlatformThread::Delegate {
// TODO(gab): Despite all of the above this test has to be disabled for now
// per crbug.com/629139#c6.
// DCHECK(owning_sequence_checker_.CalledOnValidSequence() ||
- // id_ == PlatformThread::CurrentId() || message_loop_)
- // << id_ << " vs " << PlatformThread::CurrentId();
+ // (id_event_.IsSignaled() && id_ == PlatformThread::CurrentId()) ||
+ // message_loop_);
return message_loop_;
}
@@ -205,8 +205,8 @@ class BASE_EXPORT Thread : PlatformThread::Delegate {
scoped_refptr<SingleThreadTaskRunner> task_runner() const {
// Refer to the DCHECK and comment inside |message_loop()|.
DCHECK(owning_sequence_checker_.CalledOnValidSequence() ||
- id_ == PlatformThread::CurrentId() || message_loop_)
- << id_ << " vs " << PlatformThread::CurrentId();
+ (id_event_.IsSignaled() && id_ == PlatformThread::CurrentId()) ||
+ message_loop_);
return message_loop_ ? message_loop_->task_runner() : nullptr;
}
@@ -280,7 +280,8 @@ class BASE_EXPORT Thread : PlatformThread::Delegate {
// The thread's id once it has started.
PlatformThreadId id_ = kInvalidThreadId;
- mutable WaitableEvent id_event_; // Protects |id_|.
+ // Protects |id_| which must only be read while it's signaled.
+ mutable WaitableEvent id_event_;
// The thread's MessageLoop and RunLoop. Valid only while the thread is alive.
// Set by the created thread.
« no previous file with comments | « base/synchronization/waitable_event_win.cc ('k') | base/threading/thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698