bitcoind segfault’s while loading tr descriptor on regtest v22.0 #23321

issue josef-v openend this issue on October 20, 2021
  1. josef-v commented at 9:19 am on October 20, 2021: none

    Bitcoin v22.0, tested on both self compiled and official release First of all, this happens on regtest only.

    How to reproduce:

    • run regtest instance of btc
     0$ bitcoin-cli -named createwallet wallet_name=wallet descriptors=true blank=true
     1$ cat regtest-descriptors.txt
     2[
     3  {
     4    "desc": "tr([e4445899/49'/1'/0']tprv8ZgxMBicQKsPd8jCeBWsYLEoWxbVgzJDatJ7XkwQ6G3uF4FsHuaziHQ5JZAW4K515nj6kVVwPaNWZSMEcR7aFCwL4tQqTcaoprMKTTtm6Zg/1/*)#mr3llm7f",
     5    "timestamp": 1634652324,
     6    "active": true,
     7    "internal": true,
     8    "range": [
     9      0,
    10      999
    11    ],
    12    "next": 0
    13  }
    14]
    15$ bitcoin-cli importdescriptors "$(cat regtest-descriptors.txt)"
    

    gdb log:

     0Starting program: /usr/local/bin/bitcoind > debug.log
     1warning: Error disabling address space randomization: Operation not permitted
     2[Thread debugging using libthread_db enabled]
     3Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
     4[New Thread 0x7f111c182700 (LWP 2672)]
     5[New Thread 0x7f111b981700 (LWP 2673)]
     6[New Thread 0x7f111b180700 (LWP 2674)]
     7[New Thread 0x7f111a97f700 (LWP 2675)]
     8[New Thread 0x7f111a17e700 (LWP 2676)]
     9[New Thread 0x7f111997d700 (LWP 2677)]
    10[New Thread 0x7f111917c700 (LWP 2678)]
    11[New Thread 0x7f111897b700 (LWP 2679)]
    12[New Thread 0x7f10fbfff700 (LWP 2680)]
    13[New Thread 0x7f10fb7fe700 (LWP 2681)]
    14[New Thread 0x7f10faffd700 (LWP 2682)]
    15[New Thread 0x7f10fa7fc700 (LWP 2683)]
    16[New Thread 0x7f10f9ffb700 (LWP 2684)]
    17[New Thread 0x7f10f96be700 (LWP 2685)]
    18[Thread 0x7f10f96be700 (LWP 2685) exited]
    19[New Thread 0x7f10f8ebd700 (LWP 2686)]
    20[New Thread 0x7f10dffff700 (LWP 2687)]
    21[New Thread 0x7f10df7fe700 (LWP 2688)]
    22[Thread 0x7f10dffff700 (LWP 2687) exited]
    23[New Thread 0x7f10deffd700 (LWP 2689)]
    24[New Thread 0x7f10de7fc700 (LWP 2690)]
    25
    26Thread 13 "b-httpworker.2" received signal SIGSEGV, Segmentation fault.
    27[Switching to Thread 0x7f10fa7fc700 (LWP 2683)]
    28CWallet::KeypoolCountExternalKeys (this=0x7f10e0024040) at wallet/wallet.cpp:2104
    292104    wallet/wallet.cpp: No such file or directory.
    30[#0](/bitcoin-bitcoin/0/)  CWallet::KeypoolCountExternalKeys (this=0x7f10e0024040) at wallet/wallet.cpp:2104
    31[#1](/bitcoin-bitcoin/1/)  0x0000563a086e76a3 in <lambda(const RPCHelpMan&, const JSONRPCRequest&)>::operator()(const JSONRPCRequest &, const RPCHelpMan &) (request=..., self=..., __closure=<optimized out>)
    32    at /usr/include/c++/8/bits/shared_ptr_base.h:1018
    33[#2](/bitcoin-bitcoin/2/)  0x0000563a086e8464 in std::_Function_handler<UniValue(const RPCHelpMan&, const JSONRPCRequest&), getwalletinfo()::<lambda(const RPCHelpMan&, const JSONRPCRequest&)> >::_M_invoke(const std::_Any_data &, const RPCHelpMan &, const JSONRPCRequest &) (__functor=..., __args#0=..., __args#1=...) at /usr/include/c++/8/bits/std_function.h:88
    34[#3](/bitcoin-bitcoin/3/)  0x0000563a0880a352 in std::function<UniValue (RPCHelpMan const&, JSONRPCRequest const&)>::operator()(RPCHelpMan const&, JSONRPCRequest const&) const (__args#1=..., __args#0=..., 
    35    this=0x7f10fa7fa700) at /usr/include/c++/8/bits/std_function.h:682
    36[#4](/bitcoin-bitcoin/4/)  RPCHelpMan::HandleRequest (this=this@entry=0x7f10fa7fa6e0, request=...) at rpc/util.cpp:575
    37[#5](/bitcoin-bitcoin/5/)  0x0000563a084ecf4e in CRPCCommand::CRPCCommand(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, RPCHelpMan (*)())::{lambda(JSONRPCRequest const&, UniValue&, bool)#1}::operator()(JSONRPCRequest const&, UniValue&, bool) const (__closure=<optimized out>, request=..., result=...) at ./rpc/server.h:110
    38[#6](/bitcoin-bitcoin/6/)  0x0000563a086726f8 in std::function<bool (JSONRPCRequest const&, UniValue&, bool)>::operator()(JSONRPCRequest const&, UniValue&, bool) const (__args#2=<optimized out>, __args#1=..., 
    39    __args#0=..., this=<optimized out>) at /usr/include/c++/8/bits/std_function.h:682
    40[#7](/bitcoin-bitcoin/7/)  wallet::(anonymous namespace)::WalletClientImpl::<lambda(const JSONRPCRequest&, UniValue&, bool)>::operator()(const JSONRPCRequest &, UniValue &, bool) const (
    41    __closure=0x563a0a0ed950, request=..., result=..., last_handler=<optimized out>) at wallet/interfaces.cpp:516
    42[#8](/bitcoin-bitcoin/8/)  0x0000563a0846fdf3 in std::function<bool (JSONRPCRequest const&, UniValue&, bool)>::operator()(JSONRPCRequest const&, UniValue&, bool) const (__args#2=<optimized out>, __args#1=..., 
    43    __args#0=..., this=<optimized out>) at /usr/include/c++/8/bits/std_function.h:682
    44[#9](/bitcoin-bitcoin/9/)  node::(anonymous namespace)::RpcHandlerImpl::<lambda(const JSONRPCRequest&, UniValue&, bool)>::operator() (last_handler=true, result=..., request=..., __closure=<optimized out>)
    45    at node/interfaces.cpp:397
    46[#10](/bitcoin-bitcoin/10/) std::_Function_handler<bool(const JSONRPCRequest&, UniValue&, bool), node::(anonymous namespace)::RpcHandlerImpl::RpcHandlerImpl(const CRPCCommand&)::<lambda(const JSONRPCRequest&, UniValue&, bool)> >::_M_invoke(const std::_Any_data &, const JSONRPCRequest &, UniValue &, bool &&) (__functor=..., __args#0=..., __args#1=..., __args#2=<optimized out>)
    47    at /usr/include/c++/8/bits/std_function.h:282
    48[#11](/bitcoin-bitcoin/11/) 0x0000563a08570a1e in std::function<bool (JSONRPCRequest const&, UniValue&, bool)>::operator()(JSONRPCRequest const&, UniValue&, bool) const (__args#2=<optimized out>, __args#1=..., 
    49    __args#0=..., this=0x563a0a0ed9e8) at /usr/include/c++/8/bits/std_function.h:682
    50[#12](/bitcoin-bitcoin/12/) ExecuteCommand (command=..., request=..., result=..., last_handler=<optimized out>) at rpc/server.cpp:480
    51[#13](/bitcoin-bitcoin/13/) 0x0000563a08571408 in ExecuteCommands (commands=std::vector of length 1, capacity 1 = {...}, request=..., result=...) at /usr/include/c++/8/bits/stl_iterator.h:844
    52[#14](/bitcoin-bitcoin/14/) 0x0000563a085718e8 in CRPCTable::execute (this=0x563a08c35260 <tableRPC>, request=...) at rpc/server.cpp:464
    53[#15](/bitcoin-bitcoin/15/) 0x0000563a08630c04 in HTTPReq_JSONRPC (context=..., req=0x7f10f00022f0) at httprpc.cpp:202
    54[#16](/bitcoin-bitcoin/16/) 0x0000563a08634b99 in std::function<bool (HTTPRequest*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>::operator()(HTTPRequest*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const (__args#1="", __args#0=<optimized out>, this=0x7f10f0001060) at /usr/include/c++/8/bits/std_function.h:682
    55[#17](/bitcoin-bitcoin/17/) HTTPWorkItem::operator() (this=0x7f10f0001030) at httpserver.cpp:49
    56[#18](/bitcoin-bitcoin/18/) WorkQueue<HTTPClosure>::Run (this=0x563a0a0de5e0) at httpserver.cpp:107
    57[#19](/bitcoin-bitcoin/19/) HTTPWorkQueueRun (queue=0x563a0a0de5e0, worker_num=<optimized out>) at httpserver.cpp:335
    58[#20](/bitcoin-bitcoin/20/) 0x00007f111ea90b2f in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    59[#21](/bitcoin-bitcoin/21/) 0x00007f111f1a9fa3 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
    60[#22](/bitcoin-bitcoin/22/) 0x00007f111e7704cf in clone () from /lib/x86_64-linux-gnu/libc.so.6
    

    full debug log https://pastebin.com/9nz6xi5V

  2. josef-v added the label Bug on Oct 20, 2021
  3. theStack commented at 1:48 pm on October 20, 2021: member

    Thanks for reporting! I tried to reproduce this behaviour (both on master branch and v22.0 tag), but with my setup the importdescriptors call is successful:

     0$ ./src/bitcoind -daemon -regtest
     1Bitcoin Core starting
     2$ ./src/bitcoin-cli -regtest -named createwallet wallet_name=wallet descriptors=true blank=true
     3{
     4  "name": "wallet",
     5  "warning": "Wallet is an experimental descriptor wallet"
     6}
     7$ cat regtest-descriptors.txt
     8[
     9  {
    10    "desc": "tr([e4445899/49'/1'/0']tprv8ZgxMBicQKsPd8jCeBWsYLEoWxbVgzJDatJ7XkwQ6G3uF4FsHuaziHQ5JZAW4K515nj6kVVwPaNWZSMEcR7aFCwL4tQqTcaoprMKTTtm6Zg/1/*)#mr3llm7f",
    11    "timestamp": 1634652324,
    12    "active": true,
    13    "internal": true,
    14    "range": [
    15      0,
    16      999
    17    ],
    18    "next": 0
    19  }
    20]
    21$ ./src/bitcoin-cli -regtest importdescriptors "$(cat regtest-descriptors.txt)"
    22[
    23  {
    24    "success": true
    25  }
    26]
    

    Would you mind sharing more information, e.g. the content of your bitcoin.conf (obviously you use it, since you didn’t start bitcoind with -regtest explicitely)?

  4. josef-v commented at 4:24 pm on October 20, 2021: none
    Ok, this is kind of awkward. After few hours of trying to reproduce this issue on my machine, I have found out this only happens in one of our docker images. I haven’t found the real reason yet but it seems that bitcoind doesn’t like something that our data scraping tool for prometheus does. And it also happens only if it’s regtest and if wallet with tr descriptor is loaded. I am going to investigate on this issue tomorrow, it still might be a bug in bitcoind. Or in our tool… Anyway, thanks for your time. I’ll let you know as soon as possible.
  5. josef-v commented at 7:13 am on October 21, 2021: none
    As I have promised: Another necessary step to reproduce the issue is to call getwalletinfo after setting up the wallet and importing the descriptor. I was able to reproduce it on plain debian:buster image with official binaries. I was also able to reproduce it with pkh descriptor, so it’s probably not related to taproot itself but to descriptor wallet. Wallet with wpkh descriptor worked fine (at least getwalletinfo), I didn’t try any other descriptors.
  6. theStack commented at 2:41 pm on October 21, 2021: member
    @josef-v: Thanks, with the additional call to getwalletinfo I can reproduce it now. Proposed a fix in #23333.
  7. fanquake closed this on Oct 22, 2021

  8. sidhujag referenced this in commit 10c541073f on Oct 22, 2021
  9. DrahtBot locked this on Oct 30, 2022


josef-v theStack

Labels
Bug


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-10-05 01:12 UTC

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