Bitcoin crash when -ipcconnect and -disablewallet are used together #169

issue ryanofsky openend this issue on April 7, 2025
  1. ryanofsky commented at 3:45 pm on April 7, 2025: collaborator

    Originally posted by @jimhashhq in https://github.com/bitcoin/bitcoin/issues/19461#issuecomment-2756056144

    As promised in #10102 comments, I tried out -ipcconnect using rebased pr-19641 (thank you); everything seemed to work consistent with my new understanding of multiprocess interactions (thanks again). I did notice one issue:

    1. If bitcoin-node is run with -disablewallet subsequent start of a bitcoin-gui with-ipcconnect=auto, but without -disablewallet will crash bitcoin-node. This is obviously an operator error, but may be worth handling w/o node crash. Error is:

    23329 Segmentation fault (core dumped) bitcoin-gui -conf=regtest-guisolo.conf -ipcconnect=auto -debuglogfile=bitcoin-gui-date +"%Y-%m-%d".log 2>&1

    Note: bitcoin-guiand bitcoin-node work just fine if bitcoin-gui correctly started with -disablewallet. Of interest, bitcoin-cli wallet-related RPC commands run against a bitcoin-node with -disablewallet (again, an operator error) correctly just return a Method not found RPC error and do not cause node crash.

    Please reference -disablewallet notes at docs/developer-notes.md#wallet

    Interestingly, a prior revision to docs/developer-notes.md#wallet expands on this and references an obsolete/superceded test:

    0   - *Rationale*: In RPC code that conditionally use the wallet (such as
    1     `validateaddress`) it is easy to forget that global pointer `pwalletMain`
    2     can be NULL. See `qa/rpc-tests/disablewallet.py` for functional tests
    3     exercising the API with `-disablewallet`
    

    I did not yet try and debug the crash as I’m not totally sure I built from the correct integration branch for this? Hopefully some of this is useful, thank you. See also: #19460

  2. ryanofsky commented at 4:23 pm on April 7, 2025: collaborator

    This is not technically a libmultiprocess bug but a bitcoin IPC issue exposed by https://github.com/bitcoin/bitcoin/pull/19461. Creating a separate issue to debug and track.

    I think ideal fix in long run would be for bitcoin-wallet processes to handle wallet RPC without relying on bitcoin-node, and for bitcoin-gui to communicate with bitcoin-wallet processes directly without going through bitcoin-node. At that point, the bitcoin-node -disablewallet option could be dropped.

    Before that point though, the segfault should be avoided or replaced with a clean error message.

    I could reproduce easily by building https://github.com/bitcoin/bitcoin/pull/19461 and running:

    0gdb -ex run --args build/bin/bitcoin-node -regtest -debug=ipc -disablewallet -ipcbind=unix
    1gdb -ex run --args build/bin/bitcoin-gui -regtest -debug=ipc -printtoconsole -ipcconnect=unix
    

    in two terminals. Doing that, the bitcoin-gui process appears to hang, while the bitcoin-node process has an assertion failure node/interfaces.cpp:377 walletLoader: Assertion m_context->wallet_loader’ failed.which gdb shows happening in anode::(anonymous namespace)::NodeImpl::walletLoader` call from an external thread created by the GUI.

    A reasonable fix could be to change the interfaces::Node::walletLoader() method to return a pointer rather than a reference and return a null value instead of crashing, and the GUI could handle the null value. Or it could throw an exception which the GUI could catch.

    Alternately on startup the GUI could check if the node was started with -disablewallet and avoid calling the walletLoader method if that is the case. If this is done, the walletLoader IPC method should also be changed to throw an exception in stead of asserting so the IPC call does not crash the node.


ryanofsky


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/libmultiprocess. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-12-04 19:30 UTC

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