Skip to content

wallet: Segmentation fault during sync #21605

Closed

Description

@rednil

Trying to sync my several years old wallet using bitcoin-qt on Linux WITH PRUNING ON. After 44% (around Dec. 3 2017, 16:xx), it quits with a segmentation fault. Guessing from the date, I could have made a transaction from that wallet around that time. Tried different computers with different flavors of Linux (Ubuntu 20.04, q4os 20.04) to no avail. If I am syncing without a wallet, it works.
Here, logs from a run with GDB and a subsequent backtrace (not sure if that helps, please contact me for debug info):

Reading symbols from ./bitcoin/bitcoin-0.21.0/bin/bitcoin-qt...
(No debugging symbols found in ./bitcoin/bitcoin-0.21.0/bin/bitcoin-qt)
(gdb) start
Function "main" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
Starting program: /home/chrischan/bitcoin/bitcoin-0.21.0/bin/bitcoin-qt
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff742f700 (LWP 32345)]
[New Thread 0x7ffff63dc700 (LWP 32346)]
[New Thread 0x7ffff5a9a700 (LWP 32347)]
[New Thread 0x7fffe6ffe700 (LWP 32348)]
[New Thread 0x7fffe67fd700 (LWP 32349)]
[New Thread 0x7fffc5881700 (LWP 32350)]
[New Thread 0x7fff4a870700 (LWP 32353)]
[New Thread 0x7fff42ee6700 (LWP 32354)]
[Thread 0x7fff4a870700 (LWP 32353) exited]
[New Thread 0x7fff426e5700 (LWP 32355)]
[New Thread 0x7fff41ee4700 (LWP 32356)]
[New Thread 0x7fff416e3700 (LWP 32357)]
[New Thread 0x7fff40ee2700 (LWP 32358)]
[New Thread 0x7fff2bfff700 (LWP 32359)]
[New Thread 0x7fff2b7fe700 (LWP 32360)]
[New Thread 0x7fff2affd700 (LWP 32361)]
[New Thread 0x7fff2a7fc700 (LWP 32362)]
[Thread 0x7fff41ee4700 (LWP 32356) exited]

Thread 6 "b-scheduler" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe67fd700 (LWP 32349)]
0x0000555555c2ba7b in ?? ()
(gdb) bt
#0 0x0000555555c2ba7b in ?? ()
#1 0x0000555555c4d72d in ?? ()
#2 0x0000555555c4e03d in ?? ()
#3 0x0000555555c4e454 in ?? ()
#4 0x0000555555ac964b in ?? ()
#5 0x0000555555da43b0 in ?? ()
#6 0x0000555555da31ca in ?? ()
#7 0x00005555558a097b in ?? ()
#8 0x0000555555e6e58a in ?? ()
#9 0x00007ffff7f9c609 in start_thread (arg=) at pthread_create.c:477
#10 0x00007ffff7c16293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb)

System information

V21.0, from website, verified signature

(1) Old asus EeePc, 2MB RAM, 250GB SSD
(2) Acer Laptop, 4MB RAM, 250GB SSD

Ubuntu 20.04
Q4OS (latest)

Activity

  1. sipa commented on Apr 5, 2021

    @sipa
    Member

    Can you share the last lines from debug.log?

  2. rednil commented on Apr 5, 2021

    @rednil
    Author

    Sure.

    2021-04-05T16:28:49Z Pre-allocating up to position 0xc00000 in rev01085.dat
    2021-04-05T16:28:49Z UpdateTip: new best=00000000000000000028b02bad2699993a82fc52e73936b96226296a803b6d6e height=497387 version=0x20000000 log2_work=87.579934 tx=277599023 date='2017-12-03T15:22:54Z' progress=0.440660 cache=85.0MiB(640030txo)
    2021-04-05T16:28:51Z UpdateTip: new best=0000000000000000004ea0ab05d11e558456e12e80b1e3a11614d44ea401cbdb height=497388 version=0x20000000 log2_work=87.579971 tx=277600074 date='2017-12-03T15:23:16Z' progress=0.440662 cache=85.8MiB(645919txo)
    2021-04-05T16:28:52Z UpdateTip: new best=0000000000000000003b383f9dc396a6bf46d980fa4872bdace5ecd56736a613 height=497389 version=0x20000000 log2_work=87.580007 tx=277602786 date='2017-12-03T15:27:40Z' progress=0.440666 cache=86.4MiB(650778txo)

  3. laanwj commented on Apr 5, 2021

    @laanwj
    Member

    Annotation of the backtrace address using the gitian debug information for 0.21.0 x86_64:

    (gdb) info line *0x0000555555c2ba7b
    Line 360 of "wallet/scriptpubkeyman.cpp" starts at address 0x555555c2ba79 <LegacyScriptPubKeyMan::MarkUnusedAddresses(CScript const&)+873>
       and ends at 0x555555c2ba82 <LegacyScriptPubKeyMan::MarkUnusedAddresses(CScript const&)+882>.
    
    (gdb) info line *0x0000555555c4d72d 
    Line 287 of "/usr/include/c++/7/bits/stl_tree.h" starts at address 0x555555c4d72d <CWallet::AddToWalletIfInvolvingMe(std::shared_ptr<CTransaction const> const&, CWalletTx::Confirmation, bool)+925>
       and ends at 0x555555c4d735 <CWallet::AddToWalletIfInvolvingMe(std::shared_ptr<CTransaction const> const&, CWalletTx::Confirmation, bool)+933>.
    
    (gdb) info line *0x0000555555c4e03d
    Line 1152 of "wallet/wallet.cpp" starts at address 0x555555c4e02f <CWallet::SyncTransaction(std::shared_ptr<CTransaction const> const&, CWalletTx::Confirmation, bool)+95>
       and ends at 0x555555c4e045 <CWallet::SyncTransaction(std::shared_ptr<CTransaction const> const&, CWalletTx::Confirmation, bool)+117>.
    
    (gdb) info line *0x0000555555c4e454
    Line 1217 of "wallet/wallet.cpp" starts at address 0x555555c4e42c <CWallet::blockConnected(CBlock const&, int)+220> and ends at 0x555555c4e458 <CWallet::blockConnected(CBlock const&, int)+264>.
    
    (gdb) info line *0x0000555555ac964b
    Line 222 of "validationinterface.cpp"
       starts at address 0x555555ac9638 <std::_Function_handler<void(), CMainSignals::BlockConnected(const std::shared_ptr<const CBlock>&, const CBlockIndex*)::<lambda()> >::_M_invoke(const std::_Any_data &)+760>
       and ends at 0x555555ac9670 <std::_Function_handler<void(), CMainSignals::BlockConnected(const std::shared_ptr<const CBlock>&, const CBlockIndex*)::<lambda()> >::_M_invoke(const std::_Any_data &)+816>.
    

    So this line: https://github.com/bitcoin/bitcoin/blob/v0.21.0/src/wallet/scriptpubkeyman.cpp#L360

    The only thing I can think of is some kind of out of bounds access. E.g. as far as I see it doesn't check meta.has_key_origin, nor the length of meta.key_origin.path.

    bool internal = (meta.key_origin.path[1] & ~BIP32_HARDENED_KEY_LIMIT) != 0;
  4. changed the title [-]Segmentation fault during sync[/-] [+]wallet: Segmentation fault during sync[/+] on Apr 5, 2021
  5. rednil commented on Apr 7, 2021

    @rednil
    Author

    Now I tried it without pruning. Full node completely synced, updated from 0.20.1 to 0.21.0, placed my old wallet file (not the one it was indexing before) into the "wallets" directory, started up bitcoin-qt, hit "Load Wallet", selected my file => segfault after a few seconds:

    Thread 19 "b-qt-walletctrl" received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 0x7fff457fa700 (LWP 759452)]
    0x0000555555c2ba7b in ?? ()
    (gdb) bt
    #0 0x0000555555c2ba7b in ?? ()
    #1 0x0000555555c4d72d in ?? ()
    #2 0x0000555555c4e03d in ?? ()
    #3 0x0000555555c4f2ba in ?? ()
    #4 0x0000555555c51a46 in ?? ()
    #5 0x0000555555c53e7b in ?? ()
    #6 0x0000555555b7aba5 in ?? ()
    #7 0x00005555557ffabe in ?? ()
    #8 0x00005555564ab464 in ?? ()
    #9 0x00005555564a13eb in ?? ()
    #10 0x0000555556589fbc in ?? ()
    #11 0x00005555565915ff in ?? ()
    #12 0x000055555646e288 in ?? ()
    #13 0x00005555564c6eae in ?? ()
    #14 0x00005555564c4c56 in ?? ()
    #15 0x000055555646c06f in ?? ()
    #16 0x00005555562f34ca in ?? ()
    #17 0x00005555562f5b7d in ?? ()
    #18 0x00007ffff7f98609 in start_thread (arg=)
    at pthread_create.c:477
    #19 0x00007ffff7c12293 in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
    (gdb)

    debug.log:

    2021-04-07T13:44:22Z init message: Lade Wallet...
    2021-04-07T13:44:23Z [main.dat] Wallet File Version = 139900
    2021-04-07T13:44:23Z [main.dat] Keys: 0 plaintext, 4015 encrypted, 4015 w/ metadata, 4015 total. Unknown wallet records: 0
    2021-04-07T13:44:23Z [main.dat] Wallet completed loading in 1374ms
    2021-04-07T13:44:24Z init message: Durchsuche erneut...
    2021-04-07T13:44:24Z [main.dat] Rescanning last 180900 blocks (from block 497263)...
    2021-04-07T13:44:24Z [main.dat] Rescan started from block 000000000000000000cc0bef9e18edb27c254b1294e0056fb92f02a00117abc9...
    2021-04-07T13:44:38Z New outbound peer connected: version: 70015, blocks=678167, peer=2 (full-relay)
    2021-04-07T13:44:38Z New outbound peer connected: version: 70016, blocks=678167, peer=3 (full-relay)

    The wallet file worked until quite recently, maybe 0.19 or so.

  6. zefir1990 commented on May 5, 2021

    @zefir1990

    I have two wallet.dat files, and with old wallet.dat (2014 year) everything is ok, but with another wallet.dat (2019 year) I got crash on Windows 10 that I can't trace, and crash in Ubuntu that I can trace from source code with debug mode.
    I use pruned mode (4096MB).
    Ubuntu lldb crash trace:

    lldb src/qt/bitcoin-qt
    process launch -- -reindex-chainstate -prune=4096

    • thread Monitor transactions and/or blocks #12, name = 'b-scheduler', stop reason = signal SIGSEGV: invalid address (fault address: 0x78)
      frame #0: 0x00005555557cf3c9 bitcoin-qt`CBlockIndex::GetBlockTime(this=0x0000000000000000) const at chain.h:262:25
      259
      260 int64_t GetBlockTime() const
      261 {
      -> 262 return (int64_t)nTime;
      263 }
      264
      265 int64_t GetBlockTimeMax() const

    db.log is empty
    debug.log:
    https://pastebin.com/jP6tH3PE

    lldb stack trace:
    https://pastebin.com/0n9CG0Vm

  7. DeerSpotter commented on Jun 21, 2021

    @DeerSpotter

    any updates on this

  8. rednil commented on Jun 21, 2021

    @rednil
    Author

    I found out that this was NOT my recent wallet that worked not long ago. Instead, it was possibly a VERY old, somehow corrupted wallet I already had problems with years ago. So I guess this is low prio, although it's still a segfault.

  9. achow101 commented on Oct 15, 2021

    @achow101
    Member

    The problem is likely that the wallets are encrypted and so the new fields that are being used are not actually populated at the time of use, causing the segfault. The metadata upgrade requires the private keys to be available, so the wallet needs to be unlocked.

    If you were to unlock your wallet before the problematic blocks is reached, then the upgrade will occur and there won't be a crash.

  10. zefir1990 commented on Dec 21, 2021

    @zefir1990

    Bitcoin core Qt, v22.0.0. still crashing.
    wallet.dat
    https://www.mediafire.com/file/rcf2yc3bhinztio/wallet.dat/file
    I have passphrase from it, and I don't know how to unlock it from UI, I can only change passphrase.

  11. fanquake commented on Feb 23, 2022

    @fanquake
    Member

    It's been confirmed that this is the same issue as #24335. I'm going to close this issue to consolidate discussion there. Ideally we'll get this solved for 23.0.

  12. locked and limited conversation to collaborators on Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions