[Lldb-commits] [lldb] e05af08 - [lldb/StackFrameList] Convert assert to defensive check in SynthesizeTailCallFrames

Vedant Kumar via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 4 10:44:00 PST 2020


Author: Vedant Kumar
Date: 2020-02-04T10:43:50-08:00
New Revision: e05af081bf7cbc738b2e4cdfa91054fff0153ce3

URL: https://github.com/llvm/llvm-project/commit/e05af081bf7cbc738b2e4cdfa91054fff0153ce3
DIFF: https://github.com/llvm/llvm-project/commit/e05af081bf7cbc738b2e4cdfa91054fff0153ce3.diff

LOG: [lldb/StackFrameList] Convert assert to defensive check in SynthesizeTailCallFrames

In order to synthesize tail call frames, the stack frame list must not
be empty (otherwise, there is no "previous" frame to infer a tail call
from).

This case is hard to hit. To trigger it, we must first fail to push
`unwind_frame_sp` because we either fail to get its SymbolContext, or
given its SymbolContext the GetParentOfInlineScope call fails. This
causes m_concrete_frames_fetched to be incremented while m_frames
remains empty. Then, the next frame in the stack may fail within
SynthesizeTailCallFrames. This crash arose during a kernel debugging
session.

rdar://59147051

Added: 
    

Modified: 
    lldb/source/Target/StackFrameList.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Target/StackFrameList.cpp b/lldb/source/Target/StackFrameList.cpp
index 13df807c3be4..0047697f7070 100644
--- a/lldb/source/Target/StackFrameList.cpp
+++ b/lldb/source/Target/StackFrameList.cpp
@@ -348,6 +348,11 @@ static void FindInterveningFrames(Function &begin, Function &end,
 ///   |    ...     | <- Not-yet-visited frames.
 ///   --------------
 void StackFrameList::SynthesizeTailCallFrames(StackFrame &next_frame) {
+  // Cannot synthesize tail call frames when the stack is empty (there is no
+  // "previous" frame).
+  if (m_frames.empty())
+    return;
+
   TargetSP target_sp = next_frame.CalculateTarget();
   if (!target_sp)
     return;
@@ -358,7 +363,6 @@ void StackFrameList::SynthesizeTailCallFrames(StackFrame &next_frame) {
 
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
 
-  assert(!m_frames.empty() && "Cannot synthesize frames in an empty stack");
   StackFrame &prev_frame = *m_frames.back().get();
 
   // Find the functions prev_frame and next_frame are stopped in. The function


        


More information about the lldb-commits mailing list