bitcoin/bitcoin — Issue #737: Deadlock during startup (Appears to be AddAddress / DNSSeed related)
Author: gmaxwell
Created: 2012-01-02 23:04:35+00:00
State: open

Node deadlocks sometimes shortly after startup in githead. Appears to happen when a link comes up so fast that AddAddress and DNSSeed happen concurrently.

(gdb) bt
#0 0x000000301f20b71e in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1 0x00007f11b4d790a9 in boost::this_thread::sleep(boost::posix_time::ptime const&) () from /usr/lib64/libboost_thread-mt.so.1.44.0
#2 0x000000000043e702 in sleep (argc=, argv=) at /usr/include/boost/thread/detail/thread.hpp:346
#3 Sleep (argc=, argv=) at util.h:103
#4 AppInit2 (argc=, argv=) at init.cpp:537
#5 0x000000000043f829 in AppInit (argc=, argv=) at init.cpp:112
#6 0x000000000043f8c9 in main (argc=, argv=) at init.cpp:98
(gdb) thread 0
Thread ID 0 not known.
(gdb) thread 1
[Switching to thread 1 (Thread 0x7f11b3a5a800 (LWP 415))]#0 0x000000301f20b71e in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
(gdb) bt
#0 0x000000301f20b71e in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1 0x00007f11b4d790a9 in boost::this_thread::sleep(boost::posix_time::ptime const&) () from /usr/lib64/libboost_thread-mt.so.1.44.0
#2 0x000000000043e702 in sleep (argc=, argv=) at /usr/include/boost/thread/detail/thread.hpp:346
#3 Sleep (argc=, argv=) at util.h:103
#4 AppInit2 (argc=, argv=) at init.cpp:537
#5 0x000000000043f829 in AppInit (argc=, argv=) at init.cpp:112
#6 0x000000000043f8c9 in main (argc=, argv=) at init.cpp:98
(gdb) thread 2
[Switching to thread 2 (Thread 0x7f11a57fa700 (LWP 447))]#0 0x000000301f20b3b4 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
(gdb) bt
#0 0x000000301f20b3b4 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1 0x00007f11b4a055bb in __db_pthread_mutex_lock () from /usr/lib64/libdb_cxx-4.8.so
#2 0x00007f11b4a04b72 in __db_tas_mutex_lock () from /usr/lib64/libdb_cxx-4.8.so
#3 0x00007f11b4a98984 in __lock_get_internal () from /usr/lib64/libdb_cxx-4.8.so
#4 0x00007f11b4a98e02 in __lock_get () from /usr/lib64/libdb_cxx-4.8.so
#5 0x00007f11b4ac837e in __db_lget () from /usr/lib64/libdb_cxx-4.8.so
#6 0x00007f11b4a22140 in __bam_get_root () from /usr/lib64/libdb_cxx-4.8.so
#7 0x00007f11b4a223d5 in __bam_search () from /usr/lib64/libdb_cxx-4.8.so
#8 0x00007f11b4a0dda6 in ?? () from /usr/lib64/libdb_cxx-4.8.so
#9 0x00007f11b4a121cf in ?? () from /usr/lib64/libdb_cxx-4.8.so
#10 0x00007f11b4ab83c9 in __dbc_iput () from /usr/lib64/libdb_cxx-4.8.so
#11 0x00007f11b4aba2aa in __dbc_put () from /usr/lib64/libdb_cxx-4.8.so
#12 0x00007f11b4aac4ee in __db_put () from /usr/lib64/libdb_cxx-4.8.so
#13 0x00007f11b4ac537b in __db_put_pp () from /usr/lib64/libdb_cxx-4.8.so
#14 0x00007f11b49fa2db in Db::put(DbTxn*, Dbt*, Dbt*, unsigned int) () from /usr/lib64/libdb_cxx-4.8.so
#15 0x000000000042bb32 in bool CDB::Write, std::allocator >, std::vector > >, CAddress>(std::pair, std::allocator >, std::vector > > const&, CAddress const&, bool) ()
#16 0x0000000000419402 in CAddrDB::WriteAddress (this=0x7f11a57f8a70, addr=...) at db.cpp:620
#17 0x0000000000486689 in AddressCurrentlyConnected (addr=) at net.cpp:512
#18 0x0000000000467a9c in ProcessMessage (pfrom=0x7f1198001800, strCommand="version", vRecv=) at main.cpp:2455
#19 0x000000000046b651 in ProcessMessages (pfrom=0x7f1198001800) at main.cpp:2544
#20 0x000000000048747c in ThreadMessageHandler2 (parg=) at net.cpp:1633
#21 0x000000000048767a in ThreadMessageHandler (parg=0x0) at net.cpp:1598
#22 0x000000301f206ccb in start_thread () from /lib64/libpthread.so.0
#23 0x000000301eee0c2d in clone () from /lib64/libc.so.6
(gdb) thread 3
[Switching to thread 3 (Thread 0x7f11a5ffb700 (LWP 446))]#0 0x000000301f20b71e in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
(gdb) bt
#0 0x000000301f20b71e in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1 0x00007f11b4d790a9 in boost::this_thread::sleep(boost::posix_time::ptime const&) () from /usr/lib64/libboost_thread-mt.so.1.44.0
#2 0x000000000044118d in Sleep(long long) ()
#3 0x000000000048b0f2 in ThreadOpenConnections2 (parg=) at net.cpp:1415
#4 0x000000000048baaa in ThreadOpenConnections (parg=0x0) at net.cpp:1386
#5 0x000000301f206ccb in start_thread () from /lib64/libpthread.so.0
#6 0x000000301eee0c2d in clone () from /lib64/libc.so.6
(gdb) thread 4
[Switching to thread 4 (Thread 0x7f11a67fc700 (LWP 445))]#0 0x000000301f20b71e in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
(gdb) bt
#0 0x000000301f20b71e in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1 0x00007f11b4d790a9 in boost::this_thread::sleep(boost::posix_time::ptime const&) () from /usr/lib64/libboost_thread-mt.so.1.44.0
#2 0x000000000044118d in Sleep(long long) ()
#3 0x000000000048a5a7 in ThreadSocketHandler2 (parg=) at net.cpp:1108
#4 0x000000000048a9ea in ThreadSocketHandler (parg=0x0) at net.cpp:808
#5 0x000000301f206ccb in start_thread () from /lib64/libpthread.so.0
#6 0x000000301eee0c2d in clone () from /lib64/libc.so.6
(gdb) thread 5
[Switching to thread 5 (Thread 0x7f11a77fe700 (LWP 443))]#0 0x000000301f20dc9c in __lll_lock_wait () from /lib64/libpthread.so.0
(gdb) bt
#0 0x000000301f20dc9c in __lll_lock_wait () from /lib64/libpthread.so.0
#1 0x000000301f209125 in _L_lock_880 () from /lib64/libpthread.so.0
#2 0x000000301f209008 in pthread_mutex_lock () from /lib64/libpthread.so.0
#3 0x00000000004edfc5 in lock (this=0x7640a0, pszName=, pszFile=0x5127e3 "net.cpp", nLine=)
at /usr/include/boost/interprocess/sync/posix/interprocess_recursive_mutex.hpp:53
#4 CCriticalSection::Enter (this=0x7640a0, pszName=, pszFile=0x5127e3 "net.cpp", nLine=) at util.cpp:1130
#5 0x00000000004868aa in CCriticalBlock (addr=..., nTimePenalty=, pAddrDB=0x7f11a77fdd30) at util.h:228
#6 AddAddress (addr=..., nTimePenalty=, pAddrDB=0x7f11a77fdd30) at net.cpp:451
#7 0x0000000000486f4d in ThreadDNSAddressSeed2 (parg=) at net.cpp:1286
#8 0x00000000004870ca in ThreadDNSAddressSeed (parg=0x0) at net.cpp:1253
#9 0x000000301f206ccb in start_thread () from /lib64/libpthread.so.0
#10 0x000000301eee0c2d in clone () from /lib64/libc.so.6
(gdb) thread 6
[Switching to thread 6 (Thread 0x7f11a7fff700 (LWP 442))]#0 0x000000301f20dc9c in __lll_lock_wait () from /lib64/libpthread.so.0
(gdb) bt
#0 0x000000301f20dc9c in __lll_lock_wait () from /lib64/libpthread.so.0
#1 0x000000301f209125 in _L_lock_880 () from /lib64/libpthread.so.0
#2 0x000000301f209008 in pthread_mutex_lock () from /lib64/libpthread.so.0
#3 0x00000000004edfc5 in lock (this=0x763960, pszName=, pszFile=0x513a0e "bitcoinrpc.cpp", nLine=)
at /usr/include/boost/interprocess/sync/posix/interprocess_recursive_mutex.hpp:53
#4 CCriticalSection::Enter (this=0x763960, pszName=, pszFile=0x513a0e "bitcoinrpc.cpp", nLine=)
at util.cpp:1130
#5 0x00000000004accb9 in CCriticalBlock (parg=) at util.h:228
#6 ThreadRPCServer2 (parg=) at bitcoinrpc.cpp:2422
#7 0x00000000004ad93a in ThreadRPCServer (parg=0x0) at bitcoinrpc.cpp:2249
#8 0x000000301f206ccb in start_thread () from /lib64/libpthread.so.0
#9 0x000000301eee0c2d in clone () from /lib64/libc.so.6
(gdb) thread 7
[Switching to thread 7 (Thread 0x7f11ad3c5700 (LWP 440))]#0 0x000000301f20e6ed in nanosleep () from /lib64/libpthread.so.0
(gdb) bt
#0 0x000000301f20e6ed in nanosleep () from /lib64/libpthread.so.0
#1 0x00007f11b4d79306 in boost::this_thread::sleep(boost::posix_time::ptime const&) () from /usr/lib64/libboost_thread-mt.so.1.44.0
#2 0x000000000041c176 in sleep (parg=0x16188a8) at /usr/include/boost/thread/detail/thread.hpp:346
#3 Sleep (parg=0x16188a8) at util.h:103
#4 ThreadFlushWalletDB (parg=0x16188a8) at db.cpp:995
#5 0x000000301f206ccb in start_thread () from /lib64/libpthread.so.0
#6 0x000000301eee0c2d in clone () from /lib64/libc.so.6
(gdb) thread 8
Thread ID 8 not known.