bitcoin: scheduler: crash after releasing wallet
I’ve seen this crash multiple times. It always seems to occur after closing a wallet from the gui. Have confirmed it still occurs using master (0f309541aa6dee91ac1cf6058c1ab5f51447b3c1). This has been split out of #16027.
debug.log
:
2019-05-20T09:16:13Z UpdateTip: new best=00000000000000000015161d9def3e63c1907e8804d13c9c55d3a7886b59b3c3 height=576299 version=0x20000000 log2_work=90.642833 tx=413927861 date='2019-05-16T12:25:50Z' progress=0.997033 cache=21.0MiB(159346txo)
2019-05-20T09:16:14Z UpdateTip: new best=0000000000000000002394c1e3c0d81c7c9c63920c77fbb4484e9dc02352137b height=576300 version=0x2000e000 log2_work=90.642854 tx=413930977 date='2019-05-16T12:28:52Z' progress=0.997035 cache=21.9MiB(166320txo)
2019-05-20T09:16:14Z [default wallet] Releasing wallet
2019-05-20T09:16:14Z Pre-allocating up to position 0xb00000 in rev01640.dat
2019-05-20T09:16:14Z UpdateTip: new best=000000000000000000181dc5e64237d3394afa8163d0c1d29184b4e52e6f567c height=576301 version=0x20000000 log2_work=90.642876 tx=413934113 date='2019-05-16T12:39:48Z' progress=0.997040 cache=22.7MiB(173339txo)
2019-05-20T09:16:14Z New outbound peer connected: version: 70015, blocks=576912, peer=2
2019-05-20T09:16:14Z Pre-allocating up to position 0x6000000 in blk01640.dat
2019-05-20T09:16:15Z UpdateTip: new best=00000000000000000007af1fa44f3ce1f3afc4407b08076c44536396954c1766 height=576302 version=0x20000000 log2_work=90.642897 tx=413936803 date='2019-05-16T12:41:49Z' progress=0.997042 cache=23.7MiB(180794txo)
2019-05-20T09:16:16Z UpdateTip: new best=000000000000000000033acc17d6a30317c0ef56a47fd398d67eefe4bc16cf58 height=576303 version=0x20c00000 log2_work=90.642919 tx=413939413 date='2019-05-16T12:59:49Z' progress=0.997051 cache=24.6MiB(188220txo)
2019-05-20T09:16:16Z
************************
EXCEPTION: NSt3__112system_errorE
recursive_mutex lock failed: Invalid argument
bitcoin in scheduler
2019-06-27T05:15:35Z UpdateTip: new best=000000000000050ea601ed98623e384481b8e334c90b566dddd790cd1c6d3fc0 height=188601 version=0x00000001 log2_work=68.380951 tx=4868711 date='2012-07-11T17:55:23Z' progress=0.011452 cache=275.7MiB(2041444txo)
2019-06-27T05:15:35Z [test] Releasing wallet
2019-06-27T05:15:35Z UpdateTip: new best=00000000000007154af859c8aff075f5c1a0a4d76a89c6968441169cdcd56323 height=188602 version=0x00000001 log2_work=68.380979 tx=4868862 date='2012-07-11T18:15:20Z' progress=0.011452 cache=275.7MiB(2041494txo)
2019-06-27T05:15:35Z UpdateTip: new best=00000000000005e9e4e20d35657073899bc0ce3f0604f4438733144d4693253c height=188603 version=0x00000001 log2_work=68.381007 tx=4868985 date='2012-07-11T18:17:03Z' progress=0.011452 cache=275.7MiB(2041508txo)
2019-06-27T05:15:35Z UpdateTip: new best=00000000000008942df84dd2a8989c60b3be8735d1cfa61d1f299354a7dde974 height=188604 version=0x00000001 log2_work=68.381036 tx=4869147 date='2012-07-11T18:26:03Z' progress=0.011453 cache=275.8MiB(2041621txo)
2019-06-27T05:15:35Z UpdateTip: new best=00000000000004175c1c03262a976d87f88ac4aad54e349eb4505b5194223acd height=188605 version=0x00000001 log2_work=68.381064 tx=4869187 date='2012-07-11T18:33:03Z' progress=0.011453 cache=275.8MiB(2041625txo)
2019-06-27T05:15:35Z UpdateTip: new best=000000000000043d0bfe2bdf8216c9b98aa43ce5d1d3b9abb7bbe0b1db0c1be4 height=188606 version=0x00000001 log2_work=68.381092 tx=4869729 date='2012-07-11T18:40:54Z' progress=0.011454 cache=275.7MiB(2041603txo)
2019-06-27T05:15:35Z UpdateTip: new best=00000000000007b3e12deb141b82db69845013083b2523ffa1b9da66a06191c5 height=188607 version=0x00000001 log2_work=68.38112 tx=4870331 date='2012-07-11T19:23:04Z' progress=0.011456 cache=275.8MiB(2041976txo)
2019-06-27T05:15:35Z UpdateTip: new best=00000000000007be6fe72369eb95c3431c97277616f91348aa7a3b5dd558ea48 height=188608 version=0x00000001 log2_work=68.381149 tx=4870341 date='2012-07-11T19:33:29Z' progress=0.011456 cache=275.8MiB(2041979txo)
2019-06-27T05:15:35Z UpdateTip: new best=000000000000014686e1934331d8545c986f2bd2f3eea673a7664194e419cd4d height=188609 version=0x00000001 log2_work=68.381177 tx=4871114 date='2012-07-11T19:38:03Z' progress=0.011457 cache=275.9MiB(2042711txo)
2019-06-27T05:15:35Z UpdateTip: new best=00000000000002662763d987286539ec06092398e9cb7adadf963ff543c7ae92 height=188610 version=0x00000001 log2_work=68.381205 tx=4871692 date='2012-07-11T19:47:31Z' progress=0.011459 cache=275.9MiB(2042914txo)
2019-06-27T05:15:35Z
************************
EXCEPTION: NSt3__112system_errorE
recursive_mutex lock failed: Invalid argument
bitcoin in scheduler
lldb Bitcoin-Qt.app
(lldb) target create "Bitcoin-Qt.app"
Current executable set to 'Bitcoin-Qt.app' (x86_64).
(lldb) env QT_FATAL_WARNINGS=1
(lldb) run
Process 8732 launched: '/Users/michael/github/bitcoin/Bitcoin-Qt.app/Contents/MacOS/Bitcoin-Qt' (x86_64)
2019-06-29 13:02:05.709815+0800 Bitcoin-Qt[8732:1733426] MessageTracer: Falling back to default whitelist
Process 8732 stopped
* thread #19, name = 'bitcoin-scheduler', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x00000001001b2958 Bitcoin-Qt`___lldb_unnamed_symbol14364$$Bitcoin-Qt + 40
Bitcoin-Qt`___lldb_unnamed_symbol14364$$Bitcoin-Qt:
-> 0x1001b2958 <+40>: movq (%rbx), %rcx
0x1001b295b <+43>: movq 0x20(%rcx), %rcx
0x1001b295f <+47>: movq 0xc4072a(%rip), %rdx ; (void *)0x00007fff8fc15070: __stack_chk_guard
0x1001b2966 <+54>: movq (%rdx), %rdx
Target 0: (Bitcoin-Qt) stopped.
* thread #19, name = 'bitcoin-scheduler', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
* frame #0: 0x00000001001b2958 Bitcoin-Qt`___lldb_unnamed_symbol14364$$Bitcoin-Qt + 40
frame #1: 0x00000001005139ca Bitcoin-Qt`___lldb_unnamed_symbol48305$$Bitcoin-Qt + 106
frame #2: 0x0000000100513783 Bitcoin-Qt`boost::detail::function::void_function_obj_invoker3<std::__1::__bind<void (CValidationInterface::*)(std::__1::shared_ptr<CBlock const> const&, CBlockIndex const*, std::__1::vector<std::__1::shared_ptr<CTransaction const>, std::__1::allocator<std::__1::shared_ptr<CTransaction const> > > const&), CValidationInterface*&, std::__1::placeholders::__ph<1> const&, std::__1::placeholders::__ph<2> const&, std::__1::placeholders::__ph<3> const&>, void, std::__1::shared_ptr<CBlock const> const&, CBlockIndex const*, std::__1::vector<std::__1::shared_ptr<CTransaction const>, std::__1::allocator<std::__1::shared_ptr<CTransaction const> > > const&>::invoke(boost::detail::function::function_buffer&, std::__1::shared_ptr<CBlock const> const&, CBlockIndex const*, std::__1::vector<std::__1::shared_ptr<CTransaction const>, std::__1::allocator<std::__1::shared_ptr<CTransaction const> > > const&) + 35
frame #3: 0x00000001005301a1 Bitcoin-Qt`___lldb_unnamed_symbol49499$$Bitcoin-Qt + 65
frame #4: 0x00000001005300d9 Bitcoin-Qt`___lldb_unnamed_symbol49498$$Bitcoin-Qt + 73
frame #5: 0x000000010052feaf Bitcoin-Qt`___lldb_unnamed_symbol49491$$Bitcoin-Qt + 79
frame #6: 0x000000010052fb48 Bitcoin-Qt`___lldb_unnamed_symbol49481$$Bitcoin-Qt + 72
frame #7: 0x000000010052f97b Bitcoin-Qt`___lldb_unnamed_symbol49477$$Bitcoin-Qt + 539
frame #8: 0x000000010081bee0 Bitcoin-Qt`___lldb_unnamed_symbol79231$$Bitcoin-Qt + 208
frame #9: 0x000000010081b32a Bitcoin-Qt`___lldb_unnamed_symbol79209$$Bitcoin-Qt + 378
frame #10: 0x00000001001d8a2b Bitcoin-Qt`void TraceThread<std::__1::function<void ()> >(char const*, std::__1::function<void ()>) + 91
frame #11: 0x00000001001fb894 Bitcoin-Qt`___lldb_unnamed_symbol17375$$Bitcoin-Qt + 84
frame #12: 0x0000000101090d78 libboost_thread-mt.dylib`boost::(anonymous namespace)::thread_proxy(void*) + 120
frame #13: 0x00007fff594a52eb libsystem_pthread.dylib`_pthread_body + 126
frame #14: 0x00007fff594a8249 libsystem_pthread.dylib`_pthread_start + 66
frame #15: 0x00007fff594a440d libsystem_pthread.dylib`thread_start + 13
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 20 (20 by maintainers)
Commits related to this issue
- Add open & close wallet applescript This can be used to produce the crash in https://github.com/bitcoin/bitcoin/issues/16307 — committed to fanquake/core-review by fanquake 5 years ago
From what I can tell, I’ve tracked down the cause of this crash.
A call to
CWallet::BlockConnected
while we are inwallet->Flush()
phase ofReleaseWallet
gives the scheduler thecs_wallet
lock. We then loop callingSyncTransaction
->AddToWalletIfInvolvingMe
which also callsAssertLockHeld(cs_wallet);
. At some point we’ll be done flushing, and calldelete wallet
, which blows up as we are trying to deletecs_wallet
which is still being held in the scheduler thread.You can cause this crash running
src/bitcoind
and a Python script that is essentially:debug.log
httpworker (unloadwallet) thread
scheduler thread (10)
httpworker (unloadwallet) bt
scheduler thread bt
I’ve put together an AppleScript that can reproduce this issue fairly easily. It only requires a syncing Bitcoin-Core and creating a wallet named “test”.
cc @promag.