diff options
author | Med Ismail Bennani <ismail@bennani.ma> | 2023-07-06 14:32:05 -0700 |
---|---|---|
committer | Med Ismail Bennani <ismail@bennani.ma> | 2023-07-06 14:33:52 -0700 |
commit | 1f5f4169c427c51c6919e0013c89a191dba564e8 (patch) | |
tree | 48630e805e480b76424236be2ce97ec009d2f9bf /lldb/source/Plugins/Process/scripted/ScriptedProcess.h | |
parent | 88e95c1e4bb6e2ad3bfd185b96341ad5c09eff6b (diff) | |
download | llvm-1f5f4169c427c51c6919e0013c89a191dba564e8.zip llvm-1f5f4169c427c51c6919e0013c89a191dba564e8.tar.gz llvm-1f5f4169c427c51c6919e0013c89a191dba564e8.tar.bz2 |
[lldb] Fix dead lock issue when loading modules in Scripted Process
This patch attempts to fix a dead lock when loading modules in a Scripted
Process.
This issue was triggered by loading the modules after the process did resume,
but before the process actually stop, causing the language runtime mutex to
be locked by a separate thread, responsible to unwind the stack (using
the runtime unwind plan), while the module loading thread was trying to
notify the runtimes of the newly loaded module.
To address that, this patch moves the module loading logic to be done before
sending the stop event, to prevent the dead lock situation described above.
Differential Revision: https://reviews.llvm.org/D154649
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
Diffstat (limited to 'lldb/source/Plugins/Process/scripted/ScriptedProcess.h')
-rw-r--r-- | lldb/source/Plugins/Process/scripted/ScriptedProcess.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h index 24b5a31..0335364 100644 --- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h +++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h @@ -12,6 +12,7 @@ #include "lldb/Target/Process.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/ScriptedMetadata.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Status.h" #include "ScriptedThread.h" @@ -93,6 +94,11 @@ public: void *GetImplementation() override; void ForceScriptedState(lldb::StateType state) override { + // If we're about to stop, we should fetch the loaded dynamic libraries + // dictionary before emitting the private stop event to avoid having the + // module loading happen while the process state is changing. + if (StateIsStoppedState(state, true)) + GetLoadedDynamicLibrariesInfos(); SetPrivateState(state); } |