[Lldb-commits] [lldb] r180995 - Add a hard limit to how many frames lldb will unwind in a single

Jason Molenda jmolenda at apple.com
Thu May 2 21:48:41 PDT 2013


Author: jmolenda
Date: Thu May  2 23:48:41 2013
New Revision: 180995

URL: http://llvm.org/viewvc/llvm-project?rev=180995&view=rev
Log:
Add a hard limit to how many frames lldb will unwind in a single
thread before UnwindLLDB::AddOneMoreFrame calls it quits.  We have
a couple of reports of unending backtraces in the field and we
haven't been able to collect any information about what kind of
backtrace is causing this.  We've found on Mac OS X that it's tricky
to get more than around 200k stack frames before a process exceeds
its stack space so we're starting with a hard limit of 300,000 frames.
<rdar://problem/13383069> 


Modified:
    lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp

Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp?rev=180995&r1=180994&r2=180995&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp Thu May  2 23:48:41 2013
@@ -121,6 +121,22 @@ UnwindLLDB::AddOneMoreFrame (ABI *abi)
                                                               cursor_sp->sctx, 
                                                               cur_idx, 
                                                               *this));
+
+    // We want to detect an unwind that cycles erronously and stop backtracing.
+    // Don't want this maximum unwind limit to be too low -- if you have a backtrace
+    // with an "infinitely recursing" bug, it will crash when the stack blows out
+    // and the first 35,000 frames are uninteresting - it's the top most 5 frames that
+    // you actually care about.  So you can't just cap the unwind at 10,000 or something.
+    // Realistically anything over around 200,000 is going to blow out the stack space.
+    // If we're still unwinding at that point, we're probably never going to finish.
+    if (cur_idx > 300000)
+    {
+        if (log)
+            log->Printf ("%*sFrame %d unwound too many frames, assuming unwind has gone astray, stopping.", 
+                         cur_idx < 100 ? cur_idx : 100, "", cur_idx);
+        goto unwind_done;
+    }
+
     if (reg_ctx_sp.get() == NULL)
         goto unwind_done;
 





More information about the lldb-commits mailing list