[Lldb-commits] [PATCH] D119548: [lldb] Fix race condition between lldb-vscode and stop hooks executor

Ilya Nozhkin via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 14 05:29:54 PST 2022


ilya-nozhkin added a comment.

In D119548#3318806 <https://reviews.llvm.org/D119548#3318806>, @labath wrote:

> it still seems like there is a zillion of other things that the two processes (event handler thread and stop hook executor) race on.

Stop hooks are executed in the event handler thread, so, these two particular things don't have any conflicts. Event handler thread (and stop hooks execution inside it) races with the main lldb-vscode thread (the one that handles VS Code requests).

In D119548#3318806 <https://reviews.llvm.org/D119548#3318806>, @labath wrote:

> Isn't the right fix to make sure that the event gets broadcast only after the stop hooks finish their work?

It would be cool because of some other reasons but it won't solve this particular race. I.e. we need some synchronization between stop hooks execution and the main lldb-vscode thread. So, even if the event is not broadcasted until stop hooks are executed (which means that they are executed by some other thread and it should not be the process' private state thread) then the main lldb-vscode thread will race with this thread that executes stop hooks.

In D119548#3318806 <https://reviews.llvm.org/D119548#3318806>, @labath wrote:

> How does that work on other platforms?

I've only tested it on Linux and Windows, so, I don't know whether this bug is present on other platforms. On Linux, the first stop event is pushed to the event queue of `lldb.PlatformLinux.DebugProcess.hijack` listener but then this listener gets unsubscribed from the process events and deleted, so, the first stop event is not handled at all, `DoOnRemoval` method is not invoked thus stop hooks are not executed.
In the command line mode, as I understand, the synchronicity flag is not switched as often as lldb-vscode switches it, so, it seems that the race is avoided by chance.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119548/new/

https://reviews.llvm.org/D119548



More information about the lldb-commits mailing list