[Lldb-commits] [lldb] r146478 - /lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp

Jason Molenda jmolenda at apple.com
Mon Dec 12 22:00:49 PST 2011


Author: jmolenda
Date: Tue Dec 13 00:00:49 2011
New Revision: 146478

URL: http://llvm.org/viewvc/llvm-project?rev=146478&view=rev
Log:
Add two new memory region based checks to the Unwinder:

Check that the pc value for frames up the stack is in a
mapped+executable region of memory.

Check that the stack pointer for frames up the stack is
in a mapped+readable region of memory.

If the unwinder ever makes a mistake walking the stack,
these checks will help to keep it from going too far into
the weeds.

These aren't fixing any bugs that I know of, but they
add extra robustness to a complicated task.


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

Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=146478&r1=146477&r2=146478&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Tue Dec 13 00:00:49 2011
@@ -236,6 +236,17 @@
         m_frame_type = eNotAValidFrame;
         return;
     }
+
+    // Test the pc value to see if we know it's in an unmapped/non-executable region of memory.
+    // If so, our unwind has made a mistake somewhere and we should stop.
+    uint32_t permissions;
+    if (m_thread.GetProcess().GetLoadAddressPermissions(pc, permissions)
+        && (permissions & ePermissionsExecutable) == 0)
+    {
+        m_frame_type = eNotAValidFrame;
+        return;
+    }
+
     m_thread.GetProcess().GetTarget().GetSectionLoadList().ResolveLoadAddress (pc, m_current_pc);
 
     // If we don't have a Module for some reason, we're not going to find symbol/function information - just
@@ -287,6 +298,15 @@
                     m_frame_type = eNotAValidFrame;
                     return;
                 }
+
+                // cfa_regval should point into the stack memory; if we can query memory region permissions,
+                // see if the memory is allocated & readable.
+                if (m_thread.GetProcess().GetLoadAddressPermissions(cfa_regval, permissions)
+                    && (permissions & ePermissionsReadable) == 0)
+                {
+                    m_frame_type = eNotAValidFrame;
+                    return;
+                }
             }
             else
             {





More information about the lldb-commits mailing list