Skip to content

Commit 183cb45

Browse files
authored
[lldb-dap] Fixing a race during disconnect. (llvm#135872)
While attempting to disconnect the DAP transport reader thread is setting `disconnecting` as soon as it sees a [disconnect request](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Disconnect). However, if it is processing another request when this disconnect arrives the `DAP::Loop` handler may exit the loop without replying to the disconnect request. There has been some instability on the CI jobs due to this race, for example https://lab.llvm.org/buildbot/#/builders/59/builds/16076 To address this, ensure we only return from `DAP::Loop` once we've emptied the queue.
1 parent 9483aaa commit 183cb45

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lldb/tools/lldb-dap/DAP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ llvm::Error DAP::Loop() {
921921
StopEventHandlers();
922922
});
923923

924-
while (!disconnecting) {
924+
while (!disconnecting || !m_queue.empty()) {
925925
std::unique_lock<std::mutex> lock(m_queue_mutex);
926926
m_queue_cv.wait(lock, [&] { return disconnecting || !m_queue.empty(); });
927927

0 commit comments

Comments
 (0)