diff options
author | Abseil Team <absl-team@google.com> | 2022-11-28 03:22:59 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-11-28 03:23:41 -0800 |
commit | bb7be494b385975ebdeaac3a8ee10894405641e4 (patch) | |
tree | b5c66b8314425a5113bca5e8a7d5984e9a3def4f | |
parent | 9f4bde36965c4de0781ea292fa7737a4fd60f265 (diff) |
absl: fix Mutex TSan annotations
TSan misses synchronization around passing PerThreadSynch between threads
since it happens inside of the Mutex code (which me mostly ignore),
so we need to ignore all accesses to the object.
PiperOrigin-RevId: 491297912
Change-Id: I13ea2015dee5c1a3fc4315c85112902ccffccc45
-rw-r--r-- | absl/synchronization/mutex.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/absl/synchronization/mutex.cc b/absl/synchronization/mutex.cc index dd771421..ddd8fb8d 100644 --- a/absl/synchronization/mutex.cc +++ b/absl/synchronization/mutex.cc @@ -591,10 +591,15 @@ static SynchLocksHeld *Synch_GetAllLocks() { void Mutex::IncrementSynchSem(Mutex *mu, PerThreadSynch *w) { if (mu) { ABSL_TSAN_MUTEX_PRE_DIVERT(mu, 0); - } - PerThreadSem::Post(w->thread_identity()); - if (mu) { + // We miss synchronization around passing PerThreadSynch between threads + // since it happens inside of the Mutex code, so we need to ignore all + // accesses to the object. + ABSL_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN(); + PerThreadSem::Post(w->thread_identity()); + ABSL_ANNOTATE_IGNORE_READS_AND_WRITES_END(); ABSL_TSAN_MUTEX_POST_DIVERT(mu, 0); + } else { + PerThreadSem::Post(w->thread_identity()); } } |