[Lldb-commits] [PATCH] D103609: [lldb-vscode] Synchronize calls to SendTerminatedEvent
Ayush Sahay via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Fri Jun 11 09:08:31 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5ef5177145b4: [lldb-vscode] Synchronize calls to SendTerminatedEvent (authored by asahay).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103609/new/
https://reviews.llvm.org/D103609
Files:
lldb/tools/lldb-vscode/lldb-vscode.cpp
Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===================================================================
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -179,6 +179,19 @@
// Send a "terminated" event to indicate the process is done being
// debugged.
void SendTerminatedEvent() {
+ // If an inferior exits prior to the processing of a disconnect request, then
+ // the threads executing EventThreadFunction and request_discontinue
+ // respectively may call SendTerminatedEvent simultaneously. Without any
+ // synchronization, the thread executing EventThreadFunction may set
+ // g_vsc.sent_terminated_event before the thread executing
+ // request_discontinue has had a chance to test it, in which case the latter
+ // would move ahead to issue a response to the disconnect request. Said
+ // response may get dispatched ahead of the terminated event compelling the
+ // client to terminate the debug session without consuming any console output
+ // that might've been generated by the execution of terminateCommands. So,
+ // synchronize simultaneous calls to SendTerminatedEvent.
+ static std::mutex mutex;
+ std::lock_guard<std::mutex> locker(mutex);
if (!g_vsc.sent_terminated_event) {
g_vsc.sent_terminated_event = true;
g_vsc.RunTerminateCommands();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103609.351471.patch
Type: text/x-patch
Size: 1339 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210611/6c798fa6/attachment.bin>
More information about the lldb-commits
mailing list