wallet: Duplicate wallets crash bitcoin core #16776

issue oxagast openend this issue on September 1, 2019
  1. oxagast commented at 1:43 am on September 1, 2019: none

    Opening two of the same wallet (tested in v0.18.0 of bitcoin-qt 64 bit) will cause a database collision, and will crash the program.

    [marshall@likon] {21:21} [~] $ bitcoin-0.18.0/bin/bitcoin-qt terminate called after throwing an instance of 'std::runtime_error' what(): BerkeleyBatch: Can't open database 8204388-wallet.dat (duplicates fileid 8b1c090000000800e25686350000000000000000 from 1352491-wallet.dat) Aborted (core dumped)

    I have been able to reproduce the issue by importing two of the same wallet (with different filenames).

  2. fanquake added the label Wallet on Sep 1, 2019
  3. promag commented at 1:51 am on September 1, 2019: member
    How are you loading the wallets?
  4. oxagast commented at 2:05 am on September 1, 2019: none
    File -> Open Wallet -> 8204388-wallet.dat then File -> Open Wallet -> 1352491-wallet.dat. Click the second one (which is a duplicate of the first wallet) and the GUI crashes.
  5. oxagast commented at 2:23 am on September 1, 2019: none

    Here’s a backtrace.

      0(gdb) exec-file bitcoin-0.18.0/bin/bitcoin-qt
      1(gdb) r -debug
      2Starting program: /home/marshall/bitcoin-0.18.0/bin/bitcoin-qt -debug
      3[Thread debugging using libthread_db enabled]
      4Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
      5[New Thread 0x7ffff4b38700 (LWP 22858)]
      6[New Thread 0x7fffef3ed700 (LWP 22859)]
      7[New Thread 0x7fffedff6700 (LWP 22860)]
      8[New Thread 0x7fffe6ffe700 (LWP 22861)]
      9[New Thread 0x7fffe67fd700 (LWP 22862)]
     10[New Thread 0x7fffe5ffc700 (LWP 22863)]
     11[New Thread 0x7fffe57fb700 (LWP 22864)]
     12[New Thread 0x7fffe4ffa700 (LWP 22865)]
     13[New Thread 0x7fff4ca12700 (LWP 23548)]
     14[New Thread 0x7fff47fff700 (LWP 23549)]
     15[Thread 0x7fff4ca12700 (LWP 23548) exited]
     16[New Thread 0x7fff477fe700 (LWP 23600)]
     17[New Thread 0x7fff46ffd700 (LWP 23601)]
     18[New Thread 0x7fff467fc700 (LWP 23602)]
     19[New Thread 0x7fff45ffb700 (LWP 23603)]
     20[New Thread 0x7fff457fa700 (LWP 23604)]
     21[New Thread 0x7fff44ff9700 (LWP 23607)]
     22[New Thread 0x7fff2ffff700 (LWP 23621)]
     23[New Thread 0x7fff2f7fe700 (LWP 23644)]
     24[Thread 0x7fff46ffd700 (LWP 23601) exited]
     25terminate called after throwing an instance of 'std::runtime_error'
     26  what():  BerkeleyBatch: Can't open database 8204388-wallet.dat (duplicates fileid 8b1c090000000800e25686350000000000000000 from 1352491-wallet.dat)
     27
     28Thread 17 "QThread" received signal SIGABRT, Aborted.
     29[Switching to Thread 0x7fff44ff9700 (LWP 23607)]
     30__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
     3151      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
     32(gdb) thread apply all bt
     33
     34Thread 19 (Thread 0x7fff2f7fe700 (LWP 23644)):
     35[#0](/bitcoin-bitcoin/0/)  0x00007ffff62bccf6 in __GI_ppoll (fds=0x7fff1c000fd8, nfds=1, timeout=<optimized out>, sigmask=0x0) at ../sysdeps/unix/sysv/linux/ppoll.c:39
     36[#1](/bitcoin-bitcoin/1/)  0x00005555562a6b81 in ?? ()
     37[#2](/bitcoin-bitcoin/2/)  0x0000000000000070 in ?? ()
     38[#3](/bitcoin-bitcoin/3/)  0x00005555562a95aa in ?? ()
     39[#4](/bitcoin-bitcoin/4/)  0x0000000000000001 in ?? ()
     40[#5](/bitcoin-bitcoin/5/)  0x0000000000000008 in ?? ()
     41[#6](/bitcoin-bitcoin/6/)  0x0000000000000000 in ?? ()
     42
     43Thread 18 (Thread 0x7fff2ffff700 (LWP 23621)):
     44[#0](/bitcoin-bitcoin/0/)  0x00007ffff62bccf6 in __GI_ppoll (fds=0x7fff24000d28, nfds=1, timeout=<optimized out>, sigmask=0x0) at ../sysdeps/unix/sysv/linux/ppoll.c:39
     45[#1](/bitcoin-bitcoin/1/)  0x00005555562a6b81 in ?? ()
     46[#2](/bitcoin-bitcoin/2/)  0x0000000000000070 in ?? ()
     47[#3](/bitcoin-bitcoin/3/)  0x00005555562a95aa in ?? ()
     48[#4](/bitcoin-bitcoin/4/)  0x0000000000000001 in ?? ()
     49[#5](/bitcoin-bitcoin/5/)  0x0000000000000008 in ?? ()
     50[#6](/bitcoin-bitcoin/6/)  0x0000000000000000 in ?? ()
     51
     52Thread 17 (Thread 0x7fff44ff9700 (LWP 23607)):
     53[#0](/bitcoin-bitcoin/0/)  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
     54[#1](/bitcoin-bitcoin/1/)  0x00007ffff61e8801 in __GI_abort () at abort.c:79
     55[#2](/bitcoin-bitcoin/2/)  0x000055555573edd3 in ?? ()
     56[#3](/bitcoin-bitcoin/3/)  0x0000000028062458 in ?? ()
     57[#4](/bitcoin-bitcoin/4/)  0xa6afd5bcd5adff00 in ?? ()
     58[#5](/bitcoin-bitcoin/5/)  0x00007fff28062430 in ?? ()
     59[#6](/bitcoin-bitcoin/6/)  0x000055555798e8d0 in ?? ()
     60[#7](/bitcoin-bitcoin/7/)  0x0000555556ad7050 in ?? ()
     61[#8](/bitcoin-bitcoin/8/)  0x0000555556ad0ce6 in ?? ()
     62[#9](/bitcoin-bitcoin/9/)  0x00007fff28062450 in ?? ()
     63[#10](/bitcoin-bitcoin/10/) 0x0000555556ad0d21 in ?? ()
     64[#11](/bitcoin-bitcoin/11/) 0x00007fff28062430 in ?? ()
     65[#12](/bitcoin-bitcoin/12/) 0x0000555556ac5c04 in ?? ()
     66[#13](/bitcoin-bitcoin/13/) 0x00007fff44ff8580 in ?? ()
     67[#14](/bitcoin-bitcoin/14/) 0x00007fff44ff8540 in ?? ()
     68[#15](/bitcoin-bitcoin/15/) 0x00007fffbda4c0c0 in ?? ()
     69[#16](/bitcoin-bitcoin/16/) 0x000055555571254f in ?? ()
     70[#17](/bitcoin-bitcoin/17/) 0x00007fff44ff8598 in ?? ()
     71[#18](/bitcoin-bitcoin/18/) 0x0000555556ff9353 in ?? ()
     72[#19](/bitcoin-bitcoin/19/) 0x00007fff44ff82c0 in ?? ()
     73[#20](/bitcoin-bitcoin/20/) 0x00007fffbda4c0d0 in ?? ()
     74[#21](/bitcoin-bitcoin/21/) 0x00007fff28007e78 in ?? ()
     75[#22](/bitcoin-bitcoin/22/) 0x00007fff44ff8390 in ?? ()
     76[#23](/bitcoin-bitcoin/23/) 0x0000000000000020 in ?? ()
     77[#24](/bitcoin-bitcoin/24/) 0x00000000280008d0 in ?? ()
     78[#25](/bitcoin-bitcoin/25/) 0x0000000000000000 in ?? ()
     79
     80Thread 16 (Thread 0x7fff457fa700 (LWP 23604)):
     81[#0](/bitcoin-bitcoin/0/)  0x00007ffff79bbf85 in futex_abstimed_wait_cancelable (private=<optimized out>, abstime=0x7fff457f9dc0, expected=0, futex_word=0x7fffe00a0080) at ../sysdeps/unix/sysv/linux/futex-internal.h:205
     82[#1](/bitcoin-bitcoin/1/)  __pthread_cond_wait_common (abstime=0x7fff457f9dc0, mutex=0x7fffe00a0088, cond=0x7fffe00a0058) at pthread_cond_wait.c:539
     83[#2](/bitcoin-bitcoin/2/)  __pthread_cond_timedwait (cond=0x7fffe00a0058, mutex=0x7fffe00a0088, abstime=0x7fff457f9dc0) at pthread_cond_wait.c:667
     84[#3](/bitcoin-bitcoin/3/)  0x000055555587e42e in ?? ()
     85[#4](/bitcoin-bitcoin/4/)  0x0000000000000000 in ?? ()
     86
     87Thread 15 (Thread 0x7fff45ffb700 (LWP 23603)):
     88[#0](/bitcoin-bitcoin/0/)  0x00007ffff79bbf85 in futex_abstimed_wait_cancelable (private=<optimized out>, abstime=0x7fff45ffaa40, expected=0, futex_word=0x7fffe00a00e0) at ../sysdeps/unix/sysv/linux/futex-internal.h:205
     89[#1](/bitcoin-bitcoin/1/)  __pthread_cond_wait_common (abstime=0x7fff45ffaa40, mutex=0x7fffe00a00e8, cond=0x7fffe00a00b8) at pthread_cond_wait.c:539
     90[#2](/bitcoin-bitcoin/2/)  __pthread_cond_timedwait (cond=0x7fffe00a00b8, mutex=0x7fffe00a00e8, abstime=0x7fff45ffaa40) at pthread_cond_wait.c:667
     91[#3](/bitcoin-bitcoin/3/)  0x0000555555a4eec9 in ?? ()
     92[#4](/bitcoin-bitcoin/4/)  0x00007fffe00a00e8 in ?? ()
     93[#5](/bitcoin-bitcoin/5/)  0x0000000000000001 in ?? ()
     94[#6](/bitcoin-bitcoin/6/)  0x000000005d6b2aa1 in ?? ()
     95[#7](/bitcoin-bitcoin/7/)  0x000000000d9c0739 in ?? ()
     96---Type <return> to continue, or q <return> to quit---
     97[#8](/bitcoin-bitcoin/8/)  0x000000000000208d in ?? ()
     98[#9](/bitcoin-bitcoin/9/)  0xa6afd5bcd5adff00 in ?? ()
     99[#10](/bitcoin-bitcoin/10/) 0x0000000000000000 in ?? ()
    100
    101Thread 14 (Thread 0x7fff467fc700 (LWP 23602)):
    102[#0](/bitcoin-bitcoin/0/)  0x00007ffff79bbf85 in futex_abstimed_wait_cancelable (private=<optimized out>, abstime=0x7fff467fbce0, expected=0, futex_word=0x7fffe00a00e0) at ../sysdeps/unix/sysv/linux/futex-internal.h:205
    103[#1](/bitcoin-bitcoin/1/)  __pthread_cond_wait_common (abstime=0x7fff467fbce0, mutex=0x7fffe00a00e8, cond=0x7fffe00a00b8) at pthread_cond_wait.c:539
    104[#2](/bitcoin-bitcoin/2/)  __pthread_cond_timedwait (cond=0x7fffe00a00b8, mutex=0x7fffe00a00e8, abstime=0x7fff467fbce0) at pthread_cond_wait.c:667
    105[#3](/bitcoin-bitcoin/3/)  0x0000555555a4eec9 in ?? ()
    106[#4](/bitcoin-bitcoin/4/)  0x00007fffe00a00e8 in ?? ()
    107[#5](/bitcoin-bitcoin/5/)  0xa6afd5bcd5adff01 in ?? ()
    108[#6](/bitcoin-bitcoin/6/)  0x000000005d6b2aa2 in ?? ()
    109[#7](/bitcoin-bitcoin/7/)  0x000000002332a584 in ?? ()
    110[#8](/bitcoin-bitcoin/8/)  0x00007fff467fbd50 in ?? ()
    111[#9](/bitcoin-bitcoin/9/)  0xa6afd5bcd5adff00 in ?? ()
    112[#10](/bitcoin-bitcoin/10/) 0x00007fff467fbe20 in ?? ()
    113[#11](/bitcoin-bitcoin/11/) 0x0000000000000000 in ?? ()
    114
    115Thread 12 (Thread 0x7fff477fe700 (LWP 23600)):
    116[#0](/bitcoin-bitcoin/0/)  0x00007ffff62bcbf9 in __GI___poll (fds=0x7fff480023a0, nfds=8, timeout=50) at ../sysdeps/unix/sysv/linux/poll.c:29
    117[#1](/bitcoin-bitcoin/1/)  0x000055555587ec36 in ?? ()
    118[#2](/bitcoin-bitcoin/2/)  0x0000000000000000 in ?? ()
    119
    120Thread 11 (Thread 0x7fff47fff700 (LWP 23549)):
    121[#0](/bitcoin-bitcoin/0/)  0x00007ffff62c9bb7 in epoll_wait (epfd=33, events=0x7fffbd8187c0, maxevents=32, timeout=7593) at ../sysdeps/unix/sysv/linux/epoll_wait.c:30
    122[#1](/bitcoin-bitcoin/1/)  0x0000555556abc2d9 in ?? ()
    123[#2](/bitcoin-bitcoin/2/)  0x0000000000000000 in ?? ()
    124
    125Thread 9 (Thread 0x7fffe4ffa700 (LWP 22865)):
    126[#0](/bitcoin-bitcoin/0/)  0x00007ffff79bb9f3 in futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x7fffe0ab5838) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
    127[#1](/bitcoin-bitcoin/1/)  __pthread_cond_wait_common (abstime=0x0, mutex=0x7fffe0ab57e8, cond=0x7fffe0ab5810) at pthread_cond_wait.c:502
    128[#2](/bitcoin-bitcoin/2/)  __pthread_cond_wait (cond=0x7fffe0ab5810, mutex=0x7fffe0ab57e8) at pthread_cond_wait.c:655
    129[#3](/bitcoin-bitcoin/3/)  0x0000555555c9a343 in ?? ()
    130[#4](/bitcoin-bitcoin/4/)  0x0000000000000000 in ?? ()
    131
    132Thread 8 (Thread 0x7fffe57fb700 (LWP 22864)):
    133[#0](/bitcoin-bitcoin/0/)  0x00007ffff79bbf85 in futex_abstimed_wait_cancelable (private=<optimized out>, abstime=0x7fffe57faab0, expected=0, futex_word=0x5555579b04c0) at ../sysdeps/unix/sysv/linux/futex-internal.h:205
    134[#1](/bitcoin-bitcoin/1/)  __pthread_cond_wait_common (abstime=0x7fffe57faab0, mutex=0x5555579b0470, cond=0x5555579b0498) at pthread_cond_wait.c:539
    135[#2](/bitcoin-bitcoin/2/)  __pthread_cond_timedwait (cond=0x5555579b0498, mutex=0x5555579b0470, abstime=0x7fffe57faab0) at pthread_cond_wait.c:667
    136[#3](/bitcoin-bitcoin/3/)  0x0000555555c02876 in ?? ()
    137[#4](/bitcoin-bitcoin/4/)  0x000000000000003c in ?? ()
    138[#5](/bitcoin-bitcoin/5/)  0x00007fffe57fab20 in ?? ()
    139[#6](/bitcoin-bitcoin/6/)  0x00005555579b0470 in ?? ()
    140[#7](/bitcoin-bitcoin/7/)  0x00007fffe57faaa0 in ?? ()
    141[#8](/bitcoin-bitcoin/8/)  0x00005555579b0498 in ?? ()
    142[#9](/bitcoin-bitcoin/9/)  0x00007fffe57faab0 in ?? ()
    143[#10](/bitcoin-bitcoin/10/) 0x00005555579b04c8 in ?? ()
    144[#11](/bitcoin-bitcoin/11/) 0x0000555556b56700 in ?? ()
    145[#12](/bitcoin-bitcoin/12/) 0x000000005d6b2aa1 in ?? ()
    146[#13](/bitcoin-bitcoin/13/) 0x000000000ae21d7d in ?? ()
    147[#14](/bitcoin-bitcoin/14/) 0x00007fffe57faaa0 in ?? ()
    148[#15](/bitcoin-bitcoin/15/) 0x0000000000000000 in ?? ()
    149
    150Thread 7 (Thread 0x7fffe5ffc700 (LWP 22863)):
    151[#0](/bitcoin-bitcoin/0/)  0x00007ffff79bb9f3 in futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x5555579b429c) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
    152[#1](/bitcoin-bitcoin/1/)  __pthread_cond_wait_common (abstime=0x0, mutex=0x5555579b4248, cond=0x5555579b4270) at pthread_cond_wait.c:502
    153[#2](/bitcoin-bitcoin/2/)  __pthread_cond_wait (cond=0x5555579b4270, mutex=0x5555579b4248) at pthread_cond_wait.c:655
    154[#3](/bitcoin-bitcoin/3/)  0x00005555559d8765 in ?? ()
    155[#4](/bitcoin-bitcoin/4/)  0x0000000000000000 in ?? ()
    156
    157Thread 6 (Thread 0x7fffe67fd700 (LWP 22862)):
    158[#0](/bitcoin-bitcoin/0/)  0x00007ffff79bb9f3 in futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x5555579b429c) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
    159[#1](/bitcoin-bitcoin/1/)  __pthread_cond_wait_common (abstime=0x0, mutex=0x5555579b4248, cond=0x5555579b4270) at pthread_cond_wait.c:502
    160---Type <return> to continue, or q <return> to quit---
    161[#2](/bitcoin-bitcoin/2/)  __pthread_cond_wait (cond=0x5555579b4270, mutex=0x5555579b4248) at pthread_cond_wait.c:655
    162[#3](/bitcoin-bitcoin/3/)  0x00005555559d8765 in ?? ()
    163[#4](/bitcoin-bitcoin/4/)  0x0000000000000000 in ?? ()
    164
    165Thread 5 (Thread 0x7fffe6ffe700 (LWP 22861)):
    166[#0](/bitcoin-bitcoin/0/)  0x00007ffff79bb9f3 in futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x5555579b429c) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
    167[#1](/bitcoin-bitcoin/1/)  __pthread_cond_wait_common (abstime=0x0, mutex=0x5555579b4248, cond=0x5555579b4270) at pthread_cond_wait.c:502
    168[#2](/bitcoin-bitcoin/2/)  __pthread_cond_wait (cond=0x5555579b4270, mutex=0x5555579b4248) at pthread_cond_wait.c:655
    169[#3](/bitcoin-bitcoin/3/)  0x00005555559d8765 in ?? ()
    170[#4](/bitcoin-bitcoin/4/)  0x0000000000000000 in ?? ()
    171
    172Thread 4 (Thread 0x7fffedff6700 (LWP 22860)):
    173[#0](/bitcoin-bitcoin/0/)  0x00007ffff62bccf6 in __GI_ppoll (fds=0x555557b31d48, nfds=1, timeout=<optimized out>, sigmask=0x0) at ../sysdeps/unix/sysv/linux/ppoll.c:39
    174[#1](/bitcoin-bitcoin/1/)  0x00005555562a6b81 in ?? ()
    175[#2](/bitcoin-bitcoin/2/)  0x0000000000000070 in ?? ()
    176[#3](/bitcoin-bitcoin/3/)  0x00005555562a95aa in ?? ()
    177[#4](/bitcoin-bitcoin/4/)  0x0000000000000001 in ?? ()
    178[#5](/bitcoin-bitcoin/5/)  0x0000000000000008 in ?? ()
    179[#6](/bitcoin-bitcoin/6/)  0x0000000000000000 in ?? ()
    180
    181Thread 3 (Thread 0x7fffef3ed700 (LWP 22859)):
    182[#0](/bitcoin-bitcoin/0/)  0x00007ffff62bccf6 in __GI_ppoll (fds=0x7fffe801d4b8, nfds=6, timeout=<optimized out>, sigmask=0x0) at ../sysdeps/unix/sysv/linux/ppoll.c:39
    183[#1](/bitcoin-bitcoin/1/)  0x00005555562a6b81 in ?? ()
    184[#2](/bitcoin-bitcoin/2/)  0x00007fffef3ecd30 in ?? ()
    185[#3](/bitcoin-bitcoin/3/)  0x00005555562a95aa in ?? ()
    186[#4](/bitcoin-bitcoin/4/)  0x0000000000000001 in ?? ()
    187[#5](/bitcoin-bitcoin/5/)  0x00005555562a7e74 in ?? ()
    188[#6](/bitcoin-bitcoin/6/)  0x000055555791f558 in ?? ()
    189[#7](/bitcoin-bitcoin/7/)  0xa6afd5bcd5adff00 in ?? ()
    190[#8](/bitcoin-bitcoin/8/)  0x00007fffe8040032 in ?? ()
    191[#9](/bitcoin-bitcoin/9/)  0x00007fffe8000b40 in ?? ()
    192[#10](/bitcoin-bitcoin/10/) 0x00007fffe8000bc8 in ?? ()
    193[#11](/bitcoin-bitcoin/11/) 0x0000000000000000 in ?? ()
    194
    195Thread 2 (Thread 0x7ffff4b38700 (LWP 22858)):
    196[#0](/bitcoin-bitcoin/0/)  0x00007ffff62bcbf9 in __GI___poll (fds=0x7ffff4b37d88, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
    197[#1](/bitcoin-bitcoin/1/)  0x00007ffff67bc747 in ?? () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
    198[#2](/bitcoin-bitcoin/2/)  0x00007ffff67be36a in xcb_wait_for_event () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
    199[#3](/bitcoin-bitcoin/3/)  0x0000555555cda829 in ?? ()
    200[#4](/bitcoin-bitcoin/4/)  0x0000555557b16fb0 in ?? ()
    201[#5](/bitcoin-bitcoin/5/)  0x0000555557b17310 in ?? ()
    202[#6](/bitcoin-bitcoin/6/)  0x00007ffff4b37ec8 in ?? ()
    203[#7](/bitcoin-bitcoin/7/)  0x00005555560fad65 in ?? ()
    204[#8](/bitcoin-bitcoin/8/)  0x0000000000000000 in ?? ()
    205
    206Thread 1 (Thread 0x7ffff7fbe740 (LWP 22854)):
    207[#0](/bitcoin-bitcoin/0/)  0x00007ffff62bccf6 in __GI_ppoll (fds=0x555557ffd4d8, nfds=2, timeout=<optimized out>, sigmask=0x0) at ../sysdeps/unix/sysv/linux/ppoll.c:39
    208[#1](/bitcoin-bitcoin/1/)  0x00005555562a6a90 in ?? ()
    209[#2](/bitcoin-bitcoin/2/)  0x0000555557b29fc0 in ?? ()
    210[#3](/bitcoin-bitcoin/3/)  0x00005555562a95aa in ?? ()
    211[#4](/bitcoin-bitcoin/4/)  0x0000000000000000 in ?? ()
    212(gdb)
    
  6. MarcoFalke commented at 3:08 pm on September 3, 2019: member
    Is this a bug report or feature request? Be reminded that Bitcoin Core can’t open two wallets with the same file id at the same time.
  7. MarcoFalke closed this on Sep 3, 2019

  8. practicalswift commented at 3:37 pm on September 3, 2019: contributor
    @MarcoFalke Perhaps I’m misunderstanding something here but if the user is able to achieve a core dump from the UI then we’re not handling this error condition in a very user friendly way?
  9. MarcoFalke commented at 3:41 pm on September 3, 2019: member
    Fair enough
  10. MarcoFalke reopened this on Sep 3, 2019

  11. MarcoFalke renamed this:
    Duplicate wallets crash bitcoin core (bitcoin-qt)
    gui: Duplicate wallets crash bitcoin core
    on Sep 3, 2019
  12. MarcoFalke added the label GUI on Sep 3, 2019
  13. MarcoFalke removed the label Wallet on Sep 3, 2019
  14. MarcoFalke added the label Wallet on Sep 3, 2019
  15. MarcoFalke added the label good first issue on Sep 3, 2019
  16. MarcoFalke commented at 5:15 pm on September 3, 2019: member
    It appears this is only an issue with the GUI, not with the daemon
  17. promag commented at 1:44 am on September 6, 2019: member

    No, it also affects the daemon. For instance, create copies of the default wallet and then

    0src/bitcoind -regtest -debug -wallet=wallet2.dat -wallet=wallet3.dat
    

    I think CWallet::CreateWalletFromFile should catch the exception, WDYT?

    BTW, the exception comes from CWallet::CreateWalletFromFile -> BerkeleyBatch::BerkeleyBatch -> CheckUniqueFileid.

  18. MarcoFalke renamed this:
    gui: Duplicate wallets crash bitcoin core
    wallet: Duplicate wallets crash bitcoin core
    on Sep 6, 2019
  19. MarcoFalke removed the label GUI on Sep 6, 2019
  20. MarcoFalke commented at 12:14 pm on September 6, 2019: member
    Thanks @promag. Adjusted title again
  21. promag commented at 3:02 pm on September 6, 2019: member

    Turns out that catching the exception is not enough. For instance, with the following:

     0diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
     1index cf88ab846..648b0b0ea 100644
     2--- a/src/wallet/wallet.cpp
     3+++ b/src/wallet/wallet.cpp
     4@@ -4266,7 +4266,12 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
     5     // TODO: Can't use std::make_shared because we need a custom deleter but
     6     // should be possible to use std::allocate_shared.
     7     std::shared_ptr<CWallet> walletInstance(new CWallet(&chain, location, WalletDatabase::Create(location.GetPath())), ReleaseWallet);
     8-    DBErrors nLoadWalletRet = walletInstance->LoadWallet(fFirstRun);
     9+    DBErrors nLoadWalletRet;
    10+    try {
    11+        nLoadWalletRet = walletInstance->LoadWallet(fFirstRun);
    12+    } catch (const std::runtime_error& e) {
    13+        return nullptr;
    14+    }
    15     if (nLoadWalletRet != DBErrors::LOAD_OK)
    16     {
    17         if (nLoadWalletRet == DBErrors::CORRUPT) {
    

    And then

    0src/bitcoind -regtest -wallet=wallet2.dat
    1
    2src/bitcoin-cli -regtest loadwallet wallet3.dat
    3error code: -4
    4error message:
    5Wallet loading failed.
    

    However:

     02019-09-06T14:56:36Z ThreadRPCServer method=loadwallet user=__cookie__
     12019-09-06T14:56:36Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
     22019-09-06T14:56:36Z Using wallet /Users/joao/Library/Application Support/Bitcoin/regtest/wallets/wallet3.dat
     32019-09-06T14:56:36Z init message: Loading wallet...
     42019-09-06T14:56:36Z [wallet3.dat] Releasing wallet
     52019-09-06T14:56:36Z BerkeleyEnvironment::Flush: [/Users/joao/Library/Application Support/Bitcoin/regtest/wallets] Flush(false)
     62019-09-06T14:56:36Z BerkeleyEnvironment::Flush: Flushing wallet2.dat (refcount = 0)...
     72019-09-06T14:56:36Z BerkeleyEnvironment::Flush: wallet2.dat checkpoint
     82019-09-06T14:56:36Z BerkeleyEnvironment::Flush: wallet2.dat detach
     92019-09-06T14:56:36Z BerkeleyEnvironment::Flush: wallet2.dat closed
    102019-09-06T14:56:36Z BerkeleyEnvironment::Flush: Flush(false) took              30ms
    

    So I think it messes up wallet2.dat.

  22. jonatack commented at 7:15 pm on September 19, 2019: member
    FWIW I ran across this issue today while testing #15204 (thanks @promag for the link here): #15204 (comment).
  23. GChuf commented at 10:07 am on October 14, 2019: contributor

    Was able to reproduce with 0.19.0.rc1 on Windows. Used same method as OP. In my debug.log, no info was given. When the error occurs, this is what I see (the debug log stops after this):

    02019-10-14T11:05:21Z init message: Loading wallet ...
    12019-10-14T11:05:21Z BerkeleyEnvironment::Open: LogDir=C:\Users\usr\AppData\Roaming\Bitcoin\wallets\1\database ErrorFile=C:\Users\usr\AppData\Roaming\Bitcoin\wallets\1\db.log
    22019-10-14T11:05:27Z Loading addresses from DNS seed dnsseed.emzy.de
    

    A window pops up which tells a bit more about the error. Screenshot_115

  24. fanquake deleted a comment on Jan 10, 2020
  25. brakmic commented at 8:55 pm on March 19, 2020: contributor

    Hi,

    First, I am not sure about the state of this bug and the PR related to it: #16923 , so, please, give me a hint if I am talking about things that I should not have touched.

    Anyway, I just experimented a bit, and would like to offer an alternative solution that uses the Hash160 Function to create hashes of given wallet files before the LoadWallet in load.cpp kicks in.

    This way every duplicate wallet file will be ignored, and logged.

    As shown here:

    duplicate_wallet

    Of course, it doesn’t have to be that way, as we could instead raise some error or warning message for the user. I am not sure which way is better, but regarding the fact that I don’t even know, if this experiment makes any sense, I’d rather avoid writing about the respective pros & cons.

    Here the link of the diff in my repo: https://github.com/brakmic/bitcoin/commit/e7606c8761f8e6c0381c7a5e46d9704ed71ce7e4

    There are two new functions, GetWalletHash and IsUniqueWalletHash as well as a vector for accepted wallet hashes. This vector gets cleared whenever UnloadWallets is called.

    Regards,

  26. sipa commented at 9:46 pm on March 19, 2020: member
    @brakmic I don’t think that will work, as it will only detect exactly identical wallet files, but not separate snapshots of the same wallet database at different points in time (i.e. it won’t detect loading a wallet and a restored earlier backup of the same wallet simultaneously).
  27. laanwj closed this on Apr 2, 2020

  28. sidhujag referenced this in commit fb46b04c87 on Apr 2, 2020
  29. DrahtBot locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 12:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me