thread-safety: fix annotations with REVERSE_LOCK
Without proper annotations, clang thinks that mutexes are still held for the duration of a reverse_lock. This could lead to subtle bugs as EXCLUSIVE_LOCKS_REQUIRED(foo) passes when it shouldn't. As mentioned in the docs [0], clang's thread-safety analyzer is unable to deal with aliases of mutexes, so it is not possible to use the lock's copy of the mutex for that purpose. Instead, the original mutex needs to be passed back to the reverse_lock for the sake of thread-safety analysis, but it is not actually used otherwise. [0]: https://clang.llvm.org/docs/ThreadSafetyAnalysis.html
This commit is contained in:
1 parent
aeea5f0ec1
commit
a201a99f8c
5 files changed
+21
-13
No files matched your search
@@ -83,7 +83,7 @@ public:
|
||||
for (auto it = m_list.begin(); it != m_list.end();) {
|
||||
++it->count;
|
||||
{
|
||||
REVERSE_LOCK(lock);
|
||||
REVERSE_LOCK(lock, m_mutex);
|
||||
f(*it->callbacks);
|
||||
}
|
||||
it = --it->count ? std::next(it) : m_list.erase(it);
|
||||
|
||||
Reference in new issue
Block a user