[PATCH] D29594: Add tid validation checks to blocking mutex and rw mutex
Dmitry Vyukov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 8 08:15:48 PST 2017
dvyukov added inline comments.
================
Comment at: lib/sanitizer_common/sanitizer_common.cc:77
+ u32 state = atomic_load(&state_, memory_order_relaxed);
+ CHECK((owner_ == GetTid()) ? state != kUnlocked : state == kReadLock);
+}
----------------
"state == kReadLock" must be "state >= kReadLock" because kReadLock is a counter.
Checking state != kUnlocked when owner_ == GetTid() is pointless because state is always kWriteLock when owner_ == GetTid().
This should be:
CHECK(state >= kReadLock || owner_ == GetTid());
Also note the reversed order of conditions -- syscall is slower than a check of local variable.
https://reviews.llvm.org/D29594
More information about the llvm-commits
mailing list