[Lldb-commits] [PATCH] D157159: [lldb] Properly protect the Communication class with reader/writer lock
Alex Langford via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Fri Aug 4 17:02:25 PDT 2023
bulbazord added inline comments.
================
Comment at: lldb/source/Core/Communication.cpp:41-43
Clear();
+ std::unique_lock guard(m_shared_mutex);
----------------
I think this one //may// be slightly incorrect. Here's how I imagine it going wrong:
- Thread 1 calls Connect. It only runs `Clear()` (which disconnects) and then Thread 2 is scheduled.
- Thread 2 then calls Connect. It also only runs `Clear()` and then Thread 1 is scheduled.
- Thread 1 grabs the lock, connects, and exits.
- Thread 2 also grabs the lock, connects, and exits.
I'm not sure how gracefully `Connection::Connect` handles another connection if not properly disconnected from the first url beforehand. Reading through some of the `Connection` derived class implementations of `Connect` I'm not sure exactly what will happen though. The documentation isn't much clearer either...
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157159/new/
https://reviews.llvm.org/D157159
More information about the lldb-commits
mailing list