From 8bdddcf0bb5a40e6ce6cbf7fc6b7ce576e2b032d Mon Sep 17 00:00:00 2001 From: jeffreytan81 Date: Wed, 6 Mar 2024 10:50:32 -0800 Subject: Fix lldb crash while handling concurrent vfork() (#81564) We got user reporting lldb crash while the debuggee is calling vfork() concurrently from multiple threads. The crash happens because the current implementation can only handle single vfork, vforkdone protocol transaction. This diff fixes the crash by lldb-server storing forked debuggee's pair in jstopinfo which will be decoded by lldb client to create StopInfoVFork for follow parent/child policy. Each StopInfoVFork will later have a corresponding vforkdone packet. So the patch also changes the `m_vfork_in_progress` to be reference counting based. Two new test cases are added which crash/assert without the changes in this patch. --------- Co-authored-by: jeffreytan81 --- lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp') diff --git a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp index b62e9f643fa7..26cb26daabf5 100644 --- a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp @@ -456,6 +456,9 @@ void NativeThreadLinux::SetStoppedByFork(bool is_vfork, lldb::pid_t child_pid) { m_stop_info.signo = SIGTRAP; m_stop_info.details.fork.child_pid = child_pid; m_stop_info.details.fork.child_tid = child_pid; + m_stop_description = std::to_string(child_pid); + m_stop_description += " "; + m_stop_description += std::to_string(child_pid); } void NativeThreadLinux::SetStoppedByVForkDone() { -- cgit v1.2.3