aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
diff options
context:
space:
mode:
authorFelipe de Azevedo Piovezan <fpiovezan@apple.com>2025-04-11 11:46:22 -0700
committerGitHub <noreply@github.com>2025-04-11 11:46:22 -0700
commitc2939b9bf672713ac36910a3e6d00c19ace1bd44 (patch)
tree9cf7bd68254491a63a4880c8f487a8bf24767660 /lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
parent38e64b1a84d1af0bb232833f8f6f57bd4d6e8a7a (diff)
downloadllvm-c2939b9bf672713ac36910a3e6d00c19ace1bd44.zip
llvm-c2939b9bf672713ac36910a3e6d00c19ace1bd44.tar.gz
llvm-c2939b9bf672713ac36910a3e6d00c19ace1bd44.tar.bz2
Reland "[lldb] Clear thread-creation breakpoints in ProcessGDBRemote::Clear (#134397)" (#135296)
This reapplies commit https://github.com/llvm/llvm-project/commit/232525f06942adb3b9977632e38dcd5f08c0642d. The original commit triggered a sanitizer failure when `Target` was destroyed. In `Target::Destroy`, `DeleteCurrentProcess` was called, but it did not destroy the thread creation breakpoints for the underlying `ProcessGDBRemote` because `ProcessGDBRemote::Clear` was not called in that path. `Target `then proceeded to destroy its breakpoints, which resulted in a call to the destructor of a `std::vector` containing the breakpoints. Through a sequence of complicated events, destroying breakpoints caused the reference count of the underlying `ProcessGDBRemote` to finally reach zero. This, in turn, called `ProcessGDBRemote::Clear`, which attempted to destroy the breakpoints. To do that, it would go back into the Target's vector of breakpoints, which we are in the middle of destroying. We solve this by moving the breakpoint deletion into `Process:DoDestroy`, which is a virtual Process method that will be called much earlier.
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 6836078..b616e99 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -2571,9 +2571,18 @@ Status ProcessGDBRemote::DoDestroy() {
StopAsyncThread();
KillDebugserverProcess();
+ RemoveNewThreadBreakpoints();
return Status();
}
+void ProcessGDBRemote::RemoveNewThreadBreakpoints() {
+ if (m_thread_create_bp_sp) {
+ if (TargetSP target_sp = m_target_wp.lock())
+ target_sp->RemoveBreakpointByID(m_thread_create_bp_sp->GetID());
+ m_thread_create_bp_sp.reset();
+ }
+}
+
void ProcessGDBRemote::SetLastStopPacket(
const StringExtractorGDBRemote &response) {
const bool did_exec =