[Lldb-commits] [lldb] Fix lldb crash while handling concurrent vfork() (PR #81564)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 13 12:53:45 PST 2024


================
@@ -120,15 +120,25 @@ bool NativeThreadLinux::GetStopReason(ThreadStopInfo &stop_info,
   case eStateCrashed:
   case eStateExited:
   case eStateSuspended:
-  case eStateUnloaded:
+  case eStateUnloaded: {
     if (log)
       LogThreadStopInfo(*log, m_stop_info, "m_stop_info in thread:");
     stop_info = m_stop_info;
     description = m_stop_description;
     if (log)
       LogThreadStopInfo(*log, stop_info, "returned stop_info:");
 
+    // Include child process PID/TID for forks.
+    // Client expects "<fork_pid> <fork_tid>" format.
+    if (stop_info.reason == eStopReasonFork ||
+        stop_info.reason == eStopReasonVFork) {
+      description = std::to_string(stop_info.details.fork.child_pid);
+      description += " ";
+      description += std::to_string(stop_info.details.fork.child_tid);
----------------
clayborg wrote:

Why are we adding it here and not changing the original "m_stop_description" to contain it? We want everyone to get all of the information.

If this is a human readable string, we should probably print out something like:
```
child-pid = 12345, child-tid = 345645
```
instead of two magic numbers separate by a space. 

Or is this output used in the GDB remote packets somehow? Don't we need to add the child pid and tid to the JSON stop info for the other threads in a key/value pair encoding?


https://github.com/llvm/llvm-project/pull/81564


More information about the lldb-commits mailing list