[Lldb-commits] [PATCH] D18075: Fix deadlock due to thread list locking in 'bt all' with obj-c

Francis Ricci via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 10 18:00:53 PST 2016


fjricci updated this revision to Diff 50387.
fjricci added a comment.

Remove duplication of index variable


http://reviews.llvm.org/D18075

Files:
  source/Commands/CommandObjectThread.cpp

Index: source/Commands/CommandObjectThread.cpp
===================================================================
--- source/Commands/CommandObjectThread.cpp
+++ source/Commands/CommandObjectThread.cpp
@@ -72,15 +72,18 @@
         else if (command.GetArgumentCount() == 1 && ::strcmp (command.GetArgumentAtIndex(0), "all") == 0)
         {
             Process *process = m_exe_ctx.GetProcessPtr();
-            uint32_t idx = 0;
-            for (ThreadSP thread_sp : process->Threads())
+
+            // Manually iterate to avoid locking the threadlist,
+            // which can cause deadlocks when JIT-ing code
+            ThreadList thread_list = process->GetThreadList();
+            for (uint32_t idx = 0; idx < thread_list.GetSize(); ++idx)
             {
+                ThreadSP thread_sp = thread_list.GetThreadAtIndex(idx);
                 if (idx != 0 && m_add_return)
                     result.AppendMessage("");
 
                 if (!HandleOneThread(*(thread_sp.get()), result))
                     return false;
-                ++idx;
             }
         }
         else


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18075.50387.patch
Type: text/x-patch
Size: 1104 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160311/15acbc66/attachment-0001.bin>


More information about the lldb-commits mailing list