cuitao2046 / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Deadlock with self with reentrant call to allocate memory when using tcmalloc #303

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Here is stack trace at point of deadlock:

#0  0x083f9c97 in SpinLock::SlowLock (this=0x850ea38) at 
./src/base/linux_syscall_support.h:2269
#1  0x083f3e94 in tcmalloc::CentralFreeList::Populate (this=0x850afe0) at 
src/base/spinlock.h:74
#2  0x083f3f0c in tcmalloc::CentralFreeList::FetchFromSpansSafe 
(this=0x850afe0) at src/central_freelist.cc:236
#3  0x083f3f83 in tcmalloc::CentralFreeList::RemoveRange (this=0x850afe0, 
start=0xbfffc9d0, end=0xbfffc9d4, N=1) at src/central_freelist.cc:214
#4  0x083f6321 in tcmalloc::ThreadCache::FetchFromCentralCache (this=0x8571000, 
cl=0, byte_size=2560) at src/static_vars.h:59
#5  0x0840bd0b in Allocate (size=2556) at src/thread_cache.h:339
#6  CheckedMallocResult (size=2556) at src/tcmalloc.cc:826
#7  do_malloc (size=2556) at src/tcmalloc.cc:917
#8  do_malloc_or_cpp_alloc (size=2556) at src/tcmalloc.cc:869
#9  tc_malloc (size=2556) at src/tcmalloc.cc:1308
#10 0x005111f4 in backtrace_symbols () from /lib/tls/libc.so.6
#11 0x081bdab6 in sdsPrintStacktrace () at sdsAssert.cpp:150
#12 0x081bdf4c in sdsStopHere (lineNum=900, fileName=0x8421314 "sysParam.cpp", 
functionName=0x8421700 "void <unnamed>::sdsGlobalMessageAndAbort(const 
std::string&, sdsExit::exitKind)", failingExpr=0x859ef4c "User interrupt", 
isMessage=true) at sdsAssert.cpp:245
#13 0x081793ab in (anonymous namespace)::sdsGlobalMessageAndAbort (msg=..., 
kind=sdsExit::interrupted) at sysParam.cpp:900
#14 0x0817993f in sdsGlobalSignalTermHandler (sig=2) at sysParam.cpp:957
#15 <signal handler called>
#16 0x083f5319 in tcmalloc::PageHeap::GrowHeap (this=0x8500b60, n=2) at 
src/pagemap.h:154
#17 0x083f54d0 in tcmalloc::PageHeap::New (this=0x8500b60, n=2) at 
src/page_heap.cc:89
#18 0x083f3d2b in tcmalloc::CentralFreeList::Populate (this=0x850a6e0) at 
src/static_vars.h:68
#19 0x083f3f0c in tcmalloc::CentralFreeList::FetchFromSpansSafe 
(this=0x850a6e0) at src/central_freelist.cc:236
#20 0x083f3f83 in tcmalloc::CentralFreeList::RemoveRange (this=0x850a6e0, 
start=0xbfffe29c, end=0xbfffe2a0, N=32) at src/central_freelist.cc:214
#21 0x083f6321 in tcmalloc::ThreadCache::FetchFromCentralCache (this=0x8571000, 
cl=47922, byte_size=1536) at src/static_vars.h:59
#22 0x083f220f in Allocate (size=1460, nothrow=false) at src/thread_cache.h:339
#23 CheckedMallocResult (size=1460, nothrow=false) at src/tcmalloc.cc:826
#24 do_malloc (size=1460, nothrow=false) at src/tcmalloc.cc:917
#25 (anonymous namespace)::cpp_alloc (size=1460, nothrow=false) at 
src/tcmalloc.cc:1185
#26 0x0840a4e7 in tc_new (size=1460) at src/tcmalloc.cc:1346
#27 0x081a0b08 in __gnu_cxx::new_allocator<std::_List_node<CPacket> >::allocate 
(this=0x86144b8, __n=1) at 
/usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/ext/new_alloc
ator.h:81
#28 0x081a0513 in std::_List_base<CPacket, std::allocator<CPacket> 
>::_M_get_node (this=0x86144b8) at 
/usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_list
.h:311
#29 0x0819ff14 in std::list<CPacket, std::allocator<CPacket> >::_M_create_node 
(this=0x86144b8, __x=...) at 
/usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_list
.h:435
#30 0x0819f954 in std::list<CPacket, std::allocator<CPacket> >::_M_insert 
(this=0x86144b8, __position=..., __x=...) at 
/usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_list
.h:1163
#31 0x0819f40e in std::list<CPacket, std::allocator<CPacket> >::push_back 
(this=0x86144b8, __x=...) at 
/usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_list
.h:785

Original issue reported on code.google.com by Willia...@gmail.com on 29 Jan 2011 at 7:38

GoogleCodeExporter commented 9 years ago
You are trying to get a backtrace inside a signal handler.  Unfortunately, 
backtrace() is not async-signal safe.

tcmalloc has a GetStackTrace function that was written to be async-signal safe 
-- you could try using that, though no promises (it wasn't really ever intended 
to be part of the public API).  It's processor-dependent, but should work well 
on i386, which it looks like is what you're using.

Original comment by csilv...@gmail.com on 29 Jan 2011 at 7:49