[Lldb-commits] [lldb] r257204 - Prevent infinite recursive loop in AppleObjCTrampolineHandler constructor

Stephane Sezer via lldb-commits lldb-commits at lists.llvm.org
Fri Jan 8 12:32:36 PST 2016


Author: sas
Date: Fri Jan  8 14:32:35 2016
New Revision: 257204

URL: http://llvm.org/viewvc/llvm-project?rev=257204&view=rev
Log:
Prevent infinite recursive loop in AppleObjCTrampolineHandler constructor

Summary:
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.

Reviewers: clayborg, jingham

Subscribers: sas, lldb-commits

Differential Revision: http://reviews.llvm.org/D15978

Change by Francis Ricci <fjricci at fb.com>

Modified:
    lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
    lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.h

Modified: lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp?rev=257204&r1=257203&r2=257204&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp Fri Jan  8 14:32:35 2016
@@ -72,6 +72,7 @@ lldb_private::InferiorCallMmap (Process
             options.SetTryAllThreads(true);
             options.SetDebug (false);
             options.SetTimeoutUsec(500000);
+            options.SetTrapExceptions(false);
 
             addr_t prot_arg, flags_arg = 0;
             if (prot == eMmapProtNone)
@@ -172,6 +173,7 @@ lldb_private::InferiorCallMunmap (Proces
             options.SetTryAllThreads(true);
             options.SetDebug (false);
             options.SetTimeoutUsec(500000);
+            options.SetTrapExceptions(false);
            
             AddressRange munmap_range;
             if (sc.GetAddressRange(range_scope, 0, use_inline_block_range, munmap_range))
@@ -214,7 +216,8 @@ lldb_private::InferiorCallMunmap (Proces
 bool
 lldb_private::InferiorCall (Process *process,
                             const Address *address,
-                            addr_t &returned_func)
+                            addr_t &returned_func,
+                            bool trap_exceptions)
 {
     Thread *thread = process->GetThreadList().GetSelectedThread().get();
     if (thread == NULL || address == NULL)
@@ -227,6 +230,7 @@ lldb_private::InferiorCall (Process *pro
     options.SetTryAllThreads(true);
     options.SetDebug (false);
     options.SetTimeoutUsec(500000);
+    options.SetTrapExceptions(trap_exceptions);
 
     ClangASTContext *clang_ast_context = process->GetTarget().GetScratchClangASTContext();
     CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();

Modified: lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.h?rev=257204&r1=257203&r2=257204&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.h Fri Jan  8 14:32:35 2016
@@ -31,7 +31,8 @@ bool InferiorCallMmap(Process *proc, lld
 
 bool InferiorCallMunmap(Process *proc, lldb::addr_t addr, lldb::addr_t length);
 
-bool InferiorCall(Process *proc, const Address *address, lldb::addr_t &returned_func);
+bool InferiorCall(Process *proc, const Address *address, lldb::addr_t &returned_func,
+                  bool trap_exceptions = false);
 
 }   // namespace lldb_private
 




More information about the lldb-commits mailing list