[Bug 26978] New: LLDB stack overflow while dealing with symbols for a process on Linux

Bug ID 26978
Summary LLDB stack overflow while dealing with symbols for a process on Linux
Product lldb
Version 3.8
Hardware PC
OS Linux
Status NEW
Severity release blocker
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter jeffrey.fudan@gmail.com
CC llvm-bugs@lists.llvm.org
Classification Unclassified

While using lldb to attach a process in our company on Linux, lldb segment
fault with a huge stack(more than 30K stack frames). I assume it crashes
because of stack overflow. Let me know what additional information you needed(I
have coredump):

#0  0x00007f28ce530819 in d_print_comp (dpi=0x7f28c2728c00, options=17,
dc=0x7f28c2724b80) at cp-demangle.c:4286
#1  0x00007f28ce5321e6 in d_print_comp (dpi=0x7f28c2728c00, options=17,
dc=0x7f28c2724bb0) at cp-demangle.c:4324
#2  0x00007f28ce5321e6 in d_print_comp (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, dc=0x7f28c2724c10) at cp-demangle.c:4324
#3  0x00007f28ce532010 in d_print_comp (dpi=0x7f28c2728c00, options=17,
dc=0x7f28c2724c70) at cp-demangle.c:4489
#4  0x00007f28ce5319c0 in d_print_comp (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, dc=0x7f28c2724c88) at cp-demangle.c:4923
#5  0x00007f28ce532056 in d_print_comp (dpi=0x7f28c2728c00, options=17,
dc=0x7f28c2724ca0) at cp-demangle.c:4493
#6  0x00007f28ce5321e6 in d_print_comp (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, dc=0x7f28c2724cd0) at cp-demangle.c:4324
#7  0x00007f28ce532010 in d_print_comp (dpi=0x7f28c2728c00, options=17,
dc=0x7f28c2725030) at cp-demangle.c:4489
#8  0x00007f28ce535353 in d_print_mod (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, mod=<optimized out>) at cp-demangle.c:5539
#9  0x00007f28ce535dbe in d_print_mod_list (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, mods=mods@entry=0x7f28c1f2ba30,
suffix=suffix@entry=0) at cp-demangle.c:5468
#10 0x00007f28ce5366a1 in d_print_function_type (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, mods=0x7f28c1f2ba30, dc=0x7f28c2725138) at
cp-demangle.c:5609
#11 0x00007f28ce53110c in d_print_comp (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, dc=0x7f28c2725138) at cp-demangle.c:4808
#12 0x00007f28ce530a01 in d_print_comp (dpi=0x7f28c2728c00, options=17,
dc=0x7f28c2725150) at cp-demangle.c:4434
#13 0x00007f28ce5321e6 in d_print_comp (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, dc=0x7f28c27251b0) at cp-demangle.c:4324
#14 0x00007f28ce5336b3 in d_print_comp (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, dc=0x7f28c2725108) at cp-demangle.c:4529
#15 0x00007f28ce534448 in d_print_comp (dpi=0x7f28c2728c00, options=<optimized
>, dc=0x7f28c2725270) at cp-demangle.c:4793
#16 0x00007f28ce5319c0 in d_print_comp (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, dc=0x7f28c2725288) at cp-demangle.c:4923
#17 0x00007f28ce532056 in d_print_comp (dpi=0x7f28c2728c00, options=17,
dc=0x7f28c27252a0) at cp-demangle.c:4493
#18 0x00007f28ce5321e6 in d_print_comp (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, dc=0x7f28c27252d0) at cp-demangle.c:4324
#19 0x00007f28ce534448 in d_print_comp (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, dc=0x7f28c2725318) at cp-demangle.c:4793
#20 0x00007f28ce530a01 in d_print_comp (dpi=0x7f28c2728c00, options=17,
dc=0x7f28c2725330) at cp-demangle.c:4434
#21 0x00007f28ce5321e6 in d_print_comp (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, dc=0x7f28c2725390) at cp-demangle.c:4324
#22 0x00007f28ce53123b in d_print_comp (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, dc=0x7f28c27253a8) at cp-demangle.c:4742
#23 0x00007f28ce53123b in d_print_comp (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, dc=0x7f28c27253c0) at cp-demangle.c:4742
#24 0x00007f28ce5336b3 in d_print_comp (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, dc=0x7f28c2725108) at cp-demangle.c:4529
#25 0x00007f28ce53123b in d_print_comp (dpi=0x7f28c2728c00, options=17,
dc=0x7f28c27252e8) at cp-demangle.c:4742
#26 0x00007f28ce5319c0 in d_print_comp (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, dc=0x7f28c2725300) at cp-demangle.c:4923
#27 0x00007f28ce5366e1 in d_print_function_type (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, mods=0x7f28c1f2cc70, dc=0x7f28c2725318) at
cp-demangle.c:5617
#28 0x00007f28ce53110c in d_print_comp (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, dc=0x7f28c2725318) at cp-demangle.c:4808
#29 0x00007f28ce530a01 in d_print_comp (dpi=0x7f28c2728c00, options=17,
dc=0x7f28c2725330) at cp-demangle.c:4434
....

#31767 0x00007f28ce5336b3 in d_print_comp (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, dc=0x7f28c2725108) at cp-demangle.c:4529
#31768 0x00007f28ce53123b in d_print_comp (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, dc=0x7f28c2725408) at cp-demangle.c:4742
#31769 0x00007f28ce534448 in d_print_comp (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, dc=0x7f28c2725450) at cp-demangle.c:4793
#31770 0x00007f28ce530a01 in d_print_comp (dpi=dpi@entry=0x7f28c2728c00,
options=options@entry=17, dc=dc@entry=0x7f28c2725468) at cp-demangle.c:4434
#31771 0x00007f28ce536f53 in d_demangle_callback (options=17,
opaque=0x7f28c2723cc0, callback=0x7f28ce52c820
<d_growable_string_callback_adapter>, dc=0x7f28c2725468) at cp-demangle.c:4063
#31772 0x00007f28ce536f53 in d_demangle_callback (mangled=<optimized out>,
    mangled@entry=0x0, callback=callback@entry=0x7f28ce52c820
<d_growable_string_callback_adapter>, opaque=opaque@entry=0x7f28c2728db0,
options=17) at cp-demangle.c:5865
#31773 0x00007f28ce53709f in __cxa_demangle (options=17, palc=<synthetic
>, mangled=0x0) at cp-demangle.c:5886

#31774 0x00007f28ce53709f in __cxa_demangle
(mangled_name=mangled_name@entry=0x7f28ace3d460
"_ZNSt9_Any_data9_M_accessIPPZN5folly6fibers12FiberManager16runInMainContextIZN8facebook8memcache15CacheClientImplINS6_17CControllerCommonINS1_7dynamicEEEE11multiOpSyncINS6_11McOperationILi11EEESt6vect"...,
output_buffer=output_buffer@entry=0x0, length=length@entry=0x0,
status=status@entry=0x0) at cp-demangle.c:5950
#31775 0x00007f28d015dc57 in
lldb_private::Mangled::GetDemangledName(lldb::LanguageType) const
(this=this@entry=0x7f28c0d48310,
language=language@entry=lldb::eLanguageTypeC_plus_plus)
    at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Core/Mangled.cpp:316

#31776 0x00007f28d025bdca in lldb_private::Symtab::InitNameIndexes()
(this=0x7f28ac1a8ff0) at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Symbol/Symtab.cpp:334
#31777 0x00007f28d025d0b8 in
lldb_private::Symtab::FindAllSymbolsWithNameAndType(lldb_private::ConstString
const&, lldb::SymbolType, std::vector<unsigned int, std::allocator<unsigned
> >&) (this=this@entry=0x7f28ac1a8ff0, name=...,
symbol_type=symbol_type@entry=lldb::eSymbolTypeAny, symbol_indexes=...) at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Symbol/Symtab.cpp:819

#31778 0x00007f28d0160ec2 in
lldb_private::Module::FindSymbolsWithNameAndType(lldb_private::ConstString
const&, lldb::SymbolType, lldb_private::SymbolContextList&)
(this=0x7f28ac0605a0, name=...,
symbol_type=symbol_type@entry=lldb::eSymbolTypeAny, sc_list=...) at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Core/Module.cpp:1432
#31779 0x00007f28d016781d in
lldb_private::ModuleList::FindSymbolsWithNameAndType(lldb_private::ConstString
const&, lldb::SymbolType, lldb_private::SymbolContextList&, bool) const
(this=this@entry=0x7f28c27294b0, name=...,
symbol_type=symbol_type@entry=lldb::eSymbolTypeAny, sc_list=...,
append=append@entry=false) at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Core/ModuleList.cpp:573
#31780 0x00007f28d0514626 in
JITLoaderGDB::GetSymbolAddress(lldb_private::ModuleList&,
lldb_private::ConstString const&, lldb::SymbolType) const
(this=this@entry=0x7f28ac042990, module_list=..., name=...,
symbol_type=symbol_type@entry=lldb::eSymbolTypeAny) at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp:500

#31781 0x00007f28d05164cb in
JITLoaderGDB::SetJITBreakpoint(lldb_private::ModuleList&) (this=0x7f28ac042990,
module_list=...)
    at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp:177

#31782 0x00007f28d030c910 in
lldb_private::JITLoaderList::ModulesDidLoad(lldb_private::ModuleList&)
(this=<optimized out>, module_list=...)
    at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Target/JITLoaderList.cpp:76
#31783 0x00007f28d02a90f8 in
lldb_private::Process::ModulesDidLoad(lldb_private::ModuleList&)
(this=this@entry=0x894160, module_list=...)
    at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Target/Process.cpp:6370
---Type <return> to continue, or q <return> to quit---
#31784 0x00007f28d03f3091 in
lldb_private::process_gdb_remote::ProcessGDBRemote::ModulesDidLoad(lldb_private::ModuleList&)
(this=0x894160, module_list=...)
    at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:4927
#31785 0x00007f28d02d3131 in
lldb_private::Target::ModulesDidLoad(lldb_private::ModuleList&) (this=0x88f8b0,
module_list=...)
    at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Target/Target.cpp:1400
#31786 0x00007f28d02dcb58 in
lldb_private::Target::ModuleAdded(lldb_private::ModuleList const&,
std::shared_ptr<lldb_private::Module> const&) (this=0x88f8b0, module_list=...,
module_sp=...)
    at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Target/Target.cpp:1364
#31787 0x00007f28d0168f28 in
lldb_private::ModuleList::AppendImpl(std::shared_ptr<lldb_private::Module>
const&, bool) (this=0x88fbb0, module_sp=...,
use_notifier=use_notifier@entry=true)
    at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Core/ModuleList.cpp:110
#31788 0x00007f28d0168f6a in
lldb_private::ModuleList::Append(std::shared_ptr<lldb_private::Module> const&)
(this=<optimized out>, module_sp=...)
    at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Core/ModuleList.cpp:117
#31789 0x00007f28d02d1def in
lldb_private::Target::GetSharedModule(lldb_private::ModuleSpec const&,
lldb_private::Error*) (this=this@entry=0x88f8b0, module_spec=...,
error_ptr=error_ptr@entry=0x0)
    at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Target/Target.cpp:1924
#31790 0x00007f28d0620b48 in
lldb_private::DynamicLoader::LoadModuleAtAddress(lldb_private::FileSpec const&,
unsigned long, unsigned long, bool) (this=<optimized out>, file=...,
link_map_addr=139710961516544, base_addr=139710941827072,
base_addr_is_offset=<optimized out>) at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Core/DynamicLoader.cpp:192
#31791 0x00007f28d038764a in DynamicLoaderPOSIXDYLD::LoadAllCurrentModules()
(this=0x7f28ac038570)
    at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp:521
#31792 0x00007f28d03898f0 in DynamicLoaderPOSIXDYLD::DidAttach()
(this=0x7f28ac038570)
    at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp:181
#31793 0x00007f28d02a646c in lldb_private::Process::CompleteAttach()
(this=0x894160) at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Target/Process.cpp:3443
#31794 0x00007f28d02a7236 in
lldb_private::Process::AttachCompletionHandler::PerformAction(std::shared_ptr<lldb_private::Event>&)
(this=0x8b8920, event_sp=...)
    at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Target/Process.cpp:3194
#31795 0x00007f28d02af98c in
lldb_private::Process::HandlePrivateEvent(std::shared_ptr<lldb_private::Event>&)
(this=this@entry=0x894160, event_sp=...)
    at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Target/Process.cpp:4184
#31796 0x00007f28d02b09bd in lldb_private::Process::RunPrivateStateThread(bool)
(this=0x894160, is_secondary_thread=<optimized out>)
    at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Target/Process.cpp:4429
#31797 0x00007f28d0108421 in
lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*)
(arg=0x8b8900)
    at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Host/common/HostNativeThreadBase.cpp:81
#31798 0x00007f28cea24aa1 in start_thread () at /lib64/libpthread.so.0
#31799 0x00007f28cdd8693d in clone () at /lib64/libc.so.6

Seems like the crashes happens because of abi::__cxa_demangle() for mangled symbol name " _ZNSt9_Any_data9_M_accessIPPZN5folly6fibers12FiberManager16runInMainContextIZN8facebook8memcache15CacheClientImplINS6_17CControllerCommonINS1_7dynamicEEEE11multiOpSyncINS6_11McOperationILi11EEESt6vect".

This is blocking us from releasing our C++ debugging support. Anyone know of a quick workaround I can fix it locally? Thanks!

Make stacks bigger when making threads on linux?

The cxa_demangle implementation definitely consumes stack aggressively, especially when compiled -O0. I’d definitely recommend an 8MB+ stack for any thread that may wind up demangling arbitrary C++ symbols. The new “fast demangler” is much more conservative with stack space but doesn’t yet support the full name mangling specification, so complex symbols often rely on falling back to cxa_demangle.

Kate Stone k8stone@apple.com
 Xcode Low Level Tools

The cxa_demangle implementation definitely consumes stack aggressively, especially when compiled -O0. I’d definitely recommend an 8MB+ stack for any thread that may wind up demangling arbitrary C++ symbols. The new “fast demangler” is much more conservative with stack space but doesn’t yet support the full name mangling specification, so complex symbols often rely on falling back to cxa_demangle.

Kate Stone k8stone@apple.com
 Xcode Low Level Tools

This is crazy. I tried 10MB, not working, then 20MB still not working. I got around 80K frames stack overflow, this is clearly an infinitely loop in “d_print_comp”:

(gdb) bt
#0 0x00007f35925511e1 in d_print_comp (dpi=0x7f3586747c00, options=17, dc=0x7f3586743bb0) at cp-demangle.c:4324
#1 0x00007f35925511e6 in d_print_comp (dpi=dpi@entry=0x7f3586747c00, options=options@entry=17, dc=0x7f3586743be0) at cp-demangle.c:4324
#2 0x00007f3592551010 in d_print_comp (dpi=0x7f3586747c00, options=17, dc=0x7f3586743ca0) at cp-demangle.c:4489
#3 0x00007f35925511e6 in d_print_comp (dpi=dpi@entry=0x7f3586747c00, options=options@entry=17, dc=0x7f3586743cd0) at cp-demangle.c:4324
#4 0x00007f3592551010 in d_print_comp (dpi=0x7f3586747c00, options=17, dc=0x7f3586744030) at cp-demangle.c:4489
#5 0x00007f3592554353 in d_print_mod (dpi=dpi@entry=0x7f3586747c00, options=options@entry=17, mod=) at cp-demangle.c:5539
#6 0x00007f3592554dbe in d_print_mod_list (dpi=dpi@entry=0x7f3586747c00, options=options@entry=17, mods=mods@entry=0x7f358534a7b0, suffix=suffix@entry=0) at cp-demangle.c:5468
#7 0x00007f35925556a1 in d_print_function_type (dpi=dpi@entry=0x7f3586747c00, options=options@entry=17, mods=0x7f358534a7b0, dc=0x7f3586744138) at cp-demangle.c:5609
#8 0x00007f359255010c in d_print_comp (dpi=dpi@entry=0x7f3586747c00, options=options@entry=17, dc=0x7f3586744138) at cp-demangle.c:4808
#9 0x00007f359254fa01 in d_print_comp (dpi=0x7f3586747c00, options=17, dc=0x7f3586744150) at cp-demangle.c:4434

#79590 0x00007f35925526b3 in d_print_comp (dpi=dpi@entry=0x7f3586747c00, options=options@entry=17, dc=0x7f3586744108) at cp-demangle.c:4529
#79591 0x00007f359255023b in d_print_comp (dpi=dpi@entry=0x7f3586747c00, options=options@entry=17, dc=0x7f3586744408) at cp-demangle.c:4742
#79592 0x00007f3592553448 in d_print_comp (dpi=dpi@entry=0x7f3586747c00, options=options@entry=17, dc=0x7f3586744450) at cp-demangle.c:4793
#79593 0x00007f359254fa01 in d_print_comp (dpi=dpi@entry=0x7f3586747c00, options=options@entry=17, dc=dc@entry=0x7f3586744468) at cp-demangle.c:4434
#79594 0x00007f3592555f53 in d_demangle_callback (options=17, opaque=0x7f3586742cc0, callback=0x7f359254b820 <d_growable_string_callback_adapter>, dc=0x7f3586744468) at cp-demangle.c:4063
#79595 0x00007f3592555f53 in d_demangle_callback (mangled=,
mangled@entry=0x0, callback=callback@entry=0x7f359254b820 <d_growable_string_callback_adapter>, opaque=opaque@entry=0x7f3586747db0, options=17) at cp-demangle.c:5865
#79596 0x00007f359255609f in __cxa_demangle (options=17, palc=, mangled=0x0) at cp-demangle.c:5886

#79597 0x00007f359255609f in __cxa_demangle (mangled_name=mangled_name@entry=0x7f3570e3d460 “_ZNSt9_Any_data9_M_accessIPPZN5folly6fibers12FiberManager16runInMainContextIZN8facebook8memcache15CacheClientImplINS6_17CControllerCommonINS1_7dynamicEEEE11multiOpSyncINS6_11McOperationILi11EEESt6vect”…, output_buffer=output_buffer@entry=0x0, length=length@entry=0x0, status=status@entry=0x0) at cp-demangle.c:5950
#79598 0x00007f359417cc57 in lldb_private::Mangled::GetDemangledName(lldb::LanguageType) const (this=this@entry=0x7f3584288310, language=language@entry=lldb::eLanguageTypeC_plus_plus)
at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Core/Mangled.cpp:316

#79599 0x00007f359427adca in lldb_private::Symtab::InitNameIndexes() (this=0x7f35701a8ff0) at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Symbol/Symtab.cpp:334
#79600 0x00007f359427c0b8 in lldb_private::Symtab::FindAllSymbolsWithNameAndType(lldb_private::ConstString const&, lldb::SymbolType, std::vector<unsigned int, std::allocator >&) (this=this@entry=0x7f35701a8ff0, name=…, symbol_type=symbol_type@entry=lldb::eSymbolTypeAny, symbol_indexes=…) at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Symbol/Symtab.cpp:819

#79601 0x00007f359417fec2 in lldb_private::Module::FindSymbolsWithNameAndType(lldb_private::ConstString const&, lldb::SymbolType, lldb_private::SymbolContextList&) (this=0x7f35700605a0, name=…, symbol_type=symbol_type@entry=lldb::eSymbolTypeAny, sc_list=…) at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Core/Module.cpp:1432
#79602 0x00007f359418681d in lldb_private::ModuleList::FindSymbolsWithNameAndType(lldb_private::ConstString const&, lldb::SymbolType, lldb_private::SymbolContextList&, bool) const (this=this@entry=0x7f35867484b0, name=…, symbol_type=symbol_type@entry=lldb::eSymbolTypeAny, sc_list=…, append=append@entry=false) at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Core/ModuleList.cpp:573
#79603 0x00007f3594533626 in JITLoaderGDB::GetSymbolAddress(lldb_private::ModuleList&, lldb_private::ConstString const&, lldb::SymbolType) const (this=this@entry=0x7f3570042990, module_list=…, name=…, symbol_type=symbol_type@entry=lldb::eSymbolTypeAny) at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp:500

#79604 0x00007f35945354cb in JITLoaderGDB::SetJITBreakpoint(lldb_private::ModuleList&) (this=0x7f3570042990, module_list=…)
at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp:177
#79605 0x00007f359432b910 in lldb_private::JITLoaderList::ModulesDidLoad(lldb_private::ModuleList&) (this=, module_list=…)
at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Target/JITLoaderList.cpp:76
#79606 0x00007f35942c80f8 in lldb_private::Process::ModulesDidLoad(lldb_private::ModuleList&) (this=this@entry=0x8919b0, module_list=…)
at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Target/Process.cpp:6370
#79607 0x00007f3594412091 in lldb_private::process_gdb_remote::ProcessGDBRemote::ModulesDidLoad(lldb_private::ModuleList&) (this=0x8919b0, module_list=…)
at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:4927
#79608 0x00007f35942f2131 in lldb_private::Target::ModulesDidLoad(lldb_private::ModuleList&) (this=0x88d0d0, module_list=…)
at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Target/Target.cpp:1400
#79609 0x00007f35942fbb58 in lldb_private::Target::ModuleAdded(lldb_private::ModuleList const&, std::shared_ptr<lldb_private::Module> const&) (this=0x88d0d0, module_list=…, module_sp=…)
at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Target/Target.cpp:1364
#79610 0x00007f3594187f28 in lldb_private::ModuleList::AppendImpl(std::shared_ptr<lldb_private::Module> const&, bool) (this=0x88d3d0, module_sp=…, use_notifier=use_notifier@entry=true)
at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Core/ModuleList.cpp:110
#79611 0x00007f3594187f6a in lldb_private::ModuleList::Append(std::shared_ptr<lldb_private::Module> const&) (this=, module_sp=…)
at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Core/ModuleList.cpp:117
#79612 0x00007f35942f0def in lldb_private::Target::GetSharedModule(lldb_private::ModuleSpec const&, lldb_private::Error*) (this=this@entry=0x88d0d0, module_spec=…, error_ptr=error_ptr@entry=0x0)
at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Target/Target.cpp:1924
#79613 0x00007f359463fb48 in lldb_private::DynamicLoader::LoadModuleAtAddress(lldb_private::FileSpec const&, unsigned long, unsigned long, bool) (this=, file=…, link_map_addr=139710961516544, base_addr=139710941827072, base_addr_is_offset=) at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Core/DynamicLoader.cpp:192
#79614 0x00007f35943a664a in DynamicLoaderPOSIXDYLD::LoadAllCurrentModules() (this=0x7f3570038570)
—Type to continue, or q to quit—
at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp:521
#79615 0x00007f35943a88f0 in DynamicLoaderPOSIXDYLD::DidAttach() (this=0x7f3570038570)
at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp:181
#79616 0x00007f35942c546c in lldb_private::Process::CompleteAttach() (this=0x8919b0) at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Target/Process.cpp:3443
#79617 0x00007f35942c6236 in lldb_private::Process::AttachCompletionHandler::PerformAction(std::shared_ptr<lldb_private::Event>&) (this=0x8b5f60, event_sp=…)
at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Target/Process.cpp:3194
#79618 0x00007f35942ce98c in lldb_private::Process::HandlePrivateEvent(std::shared_ptr<lldb_private::Event>&) (this=this@entry=0x8919b0, event_sp=…)
at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Target/Process.cpp:4184
#79619 0x00007f35942cf9bd in lldb_private::Process::RunPrivateStateThread(bool) (this=0x8919b0, is_secondary_thread=)
at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Target/Process.cpp:4429
#79620 0x00007f3594127421 in lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) (arg=0x8b5f40)
at /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Host/common/HostNativeThreadBase.cpp:81
#79621 0x00007f3592a43aa1 in start_thread () at /lib64/libpthread.so.0
#79622 0x00007f3591da593d in clone () at /lib64/libc.so.6

The code that has gotten itself into an infinite loop here is the libiberty cp-demangle.c, which is part of the C++ runtime libraries for the system you are on. So we can't do anything to fix bugs with that. You might make sure there isn't a newer version of that than the one on your system, but other than fixing the bugs in it yourself, there's not much we can do about that one.

However, if you build lldb with LLDB_USE_BUILTIN_DEMANGLER defined it will do two things, it will trigger the FastDemangler that Kate wrote, and if that succeeds, yay! Otherwise it will fall back to another demangler that comes along with the C++ standard libraries from the llvm project. That one, like the cp-demangle.c is very stack intensive, but it might not have whatever bug you are triggering in the libiberty one. And if it does have crashing bugs somebody in the clang world could fix them...

Anyway, you might try that and see if you have any more luck. IIRC, FreeBSD uses the llvm one in favor of the libiberty one.

Jim

Thanks Jim. This is very helpful.
We have double checked the libiberty we are building against which seems already be updated two weeks ago so this bug might not been fixed yet.
Rebuilding LLDB_USE_BUILTIN_DEMANGLER fixed this stack overflow.

Questions:

  1. Any reason LLDB_USE_BUILTIN_DEMANGLER is not used for other platforms?
  2. Any side-effect if I use LLDB_USE_BUILTIN_DEMANGLER for lldb on other platform?

Not all platforms use the same C++ name mangling. Clang follows the Itanium ABI specification which is what both the built-in LLDB demanglers understand.

Kate Stone k8stone@apple.com
 Xcode Low Level Tools

Note, g++ also uses the Itanium ABI for it’s C++ ABI, so as long as you are on a platform whose primary compiler is gcc and that isn’t very very old, either demangler will be equivalent except for bugs. The side effects of one or the other are pretty much just that you get a different set of bugs. So we let the platform owners choose the version they think best.

Jim

Yes, IIRC it’s the Microsoft compiler that uses a different mangling.

Kate Stone k8stone@apple.com
 Xcode Low Level Tools