[Lldb-commits] [PATCH] D15978: Prevent infinite recursive loop in AppleObjCTrampolineHandler constructor

Francis Ricci via lldb-commits lldb-commits at lists.llvm.org
Thu Jan 7 15:48:42 PST 2016


fjricci created this revision.
fjricci added reviewers: clayborg, jingham.
fjricci added subscribers: lldb-commits, sas.

When we construct AppleObjCTrampolineHandler, if m_impl_fn_addr is invalid, we call CanJIT(). If the gdb remote process does not support allocating and deallocating memory, this call stack will include a call to the AppleObjCRuntime constructor. The AppleObjCRuntime constructor will then call the AppleObjCTrampolineHandler constructor, creating a recursive call loop that eventually overflows the stack and segfaults.

Avoid this call loop by not constructing the AppleObjCTrampolineHandler within AppleObjCRuntime until we actually need to use it.

http://reviews.llvm.org/D15978

Files:
  source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp

Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
===================================================================
--- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -50,7 +50,6 @@
     m_objc_trampoline_handler_ap (),
     m_Foundation_major()
 {
-    ReadObjCLibraryIfNeeded (process->GetTarget().GetImages());
 }
 
 bool
@@ -76,6 +75,7 @@
 bool
 AppleObjCRuntime::GetObjectDescription (Stream &strm, Value &value, ExecutionContextScope *exe_scope)
 {
+    ReadObjCLibraryIfNeeded (m_process->GetTarget().GetImages());
     if (!m_read_objc_library)
         return false;
         
@@ -369,6 +369,7 @@
 AppleObjCRuntime::GetStepThroughTrampolinePlan (Thread &thread, bool stop_others)
 {
     ThreadPlanSP thread_plan_sp;
+    ReadObjCLibraryIfNeeded (m_process->GetTarget().GetImages());
     if (m_objc_trampoline_handler_ap.get())
         thread_plan_sp = m_objc_trampoline_handler_ap->GetStepThroughDispatchPlan (thread, stop_others);
     return thread_plan_sp;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15978.44279.patch
Type: text/x-patch
Size: 1113 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160107/c1dce223/attachment.bin>


More information about the lldb-commits mailing list