Skip to content

src/ipc/libmultiprocess/src/mp/proxy.cpp:416:44: runtime error: member access within null pointer of type 'mp::Waiter' #34711

Closed

Description

@maflcko

https://github.com/bitcoin/bitcoin/actions/runs/22486512866/job/65139128983?pr=33920#step:11:3558

test  2026-02-27T13:07:39.511298Z TestFramework (DEBUG): Calling deprecated makeMiningOld2 should raise an error 
 node0 2026-02-27T13:07:39.511430Z [capnp-loop] [ipc/capnp/protocol.cpp:50] [IpcLogFn] [ipc] {bitcoin-node-27865/b-capnp-loop-27872} IPC server recv request  #11 Init.construct$Params 
 node0 2026-02-27T13:07:39.511453Z [capnp-loop] [ipc/capnp/protocol.cpp:47] [IpcLogFn] [ipc:trace] {bitcoin-node-27865/b-capnp-loop-27872} request data: () 
 node0 2026-02-27T13:07:39.511493Z [capnp-loop] [ipc/capnp/protocol.cpp:50] [IpcLogFn] [ipc] {bitcoin-node-27865/b-capnp-loop-27872} IPC server send response #11 Init.construct$Results 
 node0 2026-02-27T13:07:39.511528Z [capnp-loop] [ipc/capnp/protocol.cpp:47] [IpcLogFn] [ipc:trace] {bitcoin-node-27865/b-capnp-loop-27872} response data: (threadMap = <external capability>) 
 node0 2026-02-27T13:07:39.511722Z [capnp-loop] [ipc/capnp/protocol.cpp:50] [IpcLogFn] [ipc] {bitcoin-node-27865/b-capnp-loop-27872} IPC server recv request  #12 Init.makeMiningOld2$Params 
 node0 2026-02-27T13:07:39.511765Z [capnp-loop] [ipc/capnp/protocol.cpp:47] [IpcLogFn] [ipc:trace] {bitcoin-node-27865/b-capnp-loop-27872} request data: () 
Error:  node0 2026-02-27T13:07:39.511806Z [capnp-loop] [ipc/capnp/protocol.cpp:59] [IpcLogFn] [error] ipc: {bitcoin-node-27865/b-capnp-loop-27872} IPC server unhandled exception: Old mining interface (@2) not supported. Please update your client! 
 test  2026-02-27T13:07:39.512059Z TestFramework (DEBUG): Closing down network thread 
 test  2026-02-27T13:07:39.562890Z TestFramework (INFO): Stopping nodes 
 test  2026-02-27T13:07:39.562975Z TestFramework.node0 (DEBUG): Stopping node 

 node0 stderr /home/admin/actions-runner/_work/_temp/src/ipc/libmultiprocess/src/mp/proxy.cpp:416:44: runtime error: member access within null pointer of type 'mp::Waiter'
    #0 0x5b9b042f9bc7 in mp::ProxyServer<mp::ThreadMap>::makeThread(capnp::CallContext<mp::ThreadMap::MakeThreadParams, mp::ThreadMap::MakeThreadResults>)::$_0::operator()() const /home/admin/actions-runner/_work/_temp/src/ipc/libmultiprocess/src/mp/proxy.cpp:416:44
    #1 0x5b9b042f9bc7 in void std::__invoke_impl<void, mp::ProxyServer<mp::ThreadMap>::makeThread(capnp::CallContext<mp::ThreadMap::MakeThreadParams, mp::ThreadMap::MakeThreadResults>)::$_0>(std::__invoke_other, mp::ProxyServer<mp::ThreadMap>::makeThread(capnp::CallContext<mp::ThreadMap::MakeThreadParams, mp::ThreadMap::MakeThreadResults>)::$_0&&) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/invoke.h:61:14
    #2 0x5b9b042f9bc7 in std::__invoke_result<mp::ProxyServer<mp::ThreadMap>::makeThread(capnp::CallContext<mp::ThreadMap::MakeThreadParams, mp::ThreadMap::MakeThreadResults>)::$_0>::type std::__invoke<mp::ProxyServer<mp::ThreadMap>::makeThread(capnp::CallContext<mp::ThreadMap::MakeThreadParams, mp::ThreadMap::MakeThreadResults>)::$_0>(mp::ProxyServer<mp::ThreadMap>::makeThread(capnp::CallContext<mp::ThreadMap::MakeThreadParams, mp::ThreadMap::MakeThreadResults>)::$_0&&) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/invoke.h:96:14
    #3 0x5b9b042f9bc7 in void std::thread::_Invoker<std::tuple<mp::ProxyServer<mp::ThreadMap>::makeThread(capnp::CallContext<mp::ThreadMap::MakeThreadParams, mp::ThreadMap::MakeThreadResults>)::$_0>>::_M_invoke<0ul>(std::_Index_tuple<0ul>) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_thread.h:292:13
    #4 0x5b9b042f9bc7 in std::thread::_Invoker<std::tuple<mp::ProxyServer<mp::ThreadMap>::makeThread(capnp::CallContext<mp::ThreadMap::MakeThreadParams, mp::ThreadMap::MakeThreadResults>)::$_0>>::operator()() /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_thread.h:299:11
    #5 0x5b9b042f9bc7 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<mp::ProxyServer<mp::ThreadMap>::makeThread(capnp::CallContext<mp::ThreadMap::MakeThreadParams, mp::ThreadMap::MakeThreadResults>)::$_0>>>::_M_run() /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_thread.h:244:13
    #6 0x7e490caa7db3  (/lib/x86_64-linux-gnu/libstdc++.so.6+0xecdb3) (BuildId: 753c6c8608b61d4e67be8f0c890e03e0aa046b8b)
    #7 0x5b9b02f157da in asan_thread_start(void*) crtstuff.c
    #8 0x7e490c719aa3  (/lib/x86_64-linux-gnu/libc.so.6+0x9caa3) (BuildId: 8e9fd827446c24067541ac5390e6f527fb5947bb)
    #9 0x7e490c7a6c6b  (/lib/x86_64-linux-gnu/libc.so.6+0x129c6b) (BuildId: 8e9fd827446c24067541ac5390e6f527fb5947bb)

SUMMARY: UndefinedBehaviorSanitizer: null-pointer-use /home/admin/actions-runner/_work/_temp/src/ipc/libmultiprocess/src/mp/proxy.cpp:416:44 

https://github.com/bitcoin/bitcoin/actions/runs/22507213959/job/65208454067?pr=32575#step:9:2602:

test  2026-02-27T23:11:14.432126Z TestFramework (DEBUG): Calling deprecated makeMiningOld2 should raise an error 
 node0 2026-02-27T23:11:14.433082Z [capnp-loop] [ipc/capnp/protocol.cpp:53] [IpcLogFn] ipc: {bitcoin-node-27102/b-capnp-loop-27137} IPC server destroy N2mp11ProxyServerIN3ipc5capnp8messages6MiningEEE 
 node0 2026-02-27T23:11:14.433137Z [capnp-loop] [ipc/capnp/protocol.cpp:50] [IpcLogFn] [ipc] {bitcoin-node-27102/b-capnp-loop-27137} IPC server recv request  #11 Init.construct$Params 
 node0 2026-02-27T23:11:14.433143Z [capnp-loop] [ipc/capnp/protocol.cpp:47] [IpcLogFn] [ipc:trace] {bitcoin-node-27102/b-capnp-loop-27137} request data: () 
 node0 2026-02-27T23:11:14.433151Z [capnp-loop] [ipc/capnp/protocol.cpp:50] [IpcLogFn] [ipc] {bitcoin-node-27102/b-capnp-loop-27137} IPC server send response #11 Init.construct$Results 
 node0 2026-02-27T23:11:14.433156Z [capnp-loop] [ipc/capnp/protocol.cpp:47] [IpcLogFn] [ipc:trace] {bitcoin-node-27102/b-capnp-loop-27137} response data: (threadMap = <external capability>) 
 node0 2026-02-27T23:11:14.433243Z [capnp-loop] [ipc/capnp/protocol.cpp:50] [IpcLogFn] [ipc] {bitcoin-node-27102/b-capnp-loop-27137} IPC server recv request  #12 Init.makeMiningOld2$Params 
 node0 2026-02-27T23:11:14.433255Z [capnp-loop] [ipc/capnp/protocol.cpp:47] [IpcLogFn] [ipc:trace] {bitcoin-node-27102/b-capnp-loop-27137} request data: () 
Error: 2026-02-27T23:11:14.433271Z [capnp-loop] [ipc/capnp/protocol.cpp:59] [IpcLogFn] [error] ipc: {bitcoin-node-27102/b-capnp-loop-27137} IPC server unhandled exception: Old mining interface (@2) not supported. Please update your client! 
 node0 2026-02-27T23:11:14.433329Z [capnp-loop] [ipc/capnp/protocol.cpp:53] [IpcLogFn] ipc: {bitcoin-node-27102/b-capnp-loop-27137} IPC server: socket disconnected. 
 node0 2026-02-27T23:11:14.433334Z [capnp-loop] [ipc/capnp/protocol.cpp:53] [IpcLogFn] ipc: {bitcoin-node-27102/b-capnp-loop-27137} IPC server destroy N2mp11ProxyServerIN3ipc5capnp8messages4InitEEE 
 test  2026-02-27T23:11:14.433542Z TestFramework (DEBUG): Closing down network thread 
 test  2026-02-27T23:11:14.485263Z TestFramework (INFO): Stopping nodes 
 test  2026-02-27T23:11:14.485316Z TestFramework.node0 (DEBUG): Stopping node 


Activity

  1. added theissue type on Mar 2, 2026
  2. added this to the 31.0 milestone on Mar 2, 2026
  3. fanquake commented on Mar 2, 2026

    @fanquake
    Member
  4. ryanofsky commented on Mar 2, 2026

    @ryanofsky
    Contributor

    Thanks for the clear report! It seems like this problem was introduced in #34568 with the new run_deprecated_mining_test.

    The stack trace shows the problem is a null g_thread_context.waiter pointer being dereferenced in ProxyServer<ThreadMap>::makeThread which is creating a worker thread. That pointer is only set to null in ProxyServer<Thread>::~ProxyServer when the worker thread is being destroyed. So the issue is just that the worker thread is destroyed too quickly after it is created, resulting in a null pointer use since it gets destroyed before it is fully initialized. A direct fix for this problem would be:

    --- a/src/ipc/libmultiprocess/src/mp/proxy.cpp
    +++ b/src/ipc/libmultiprocess/src/mp/proxy.cpp
    @@ -412,8 +412,8 @@ kj::Promise<void> ProxyServer<ThreadMap>::makeThread(MakeThreadContext context)
         std::thread thread([&thread_context, from, this]() {
             g_thread_context.thread_name = ThreadName(m_connection.m_loop->m_exe_name) + " (from " + from + ")";
             g_thread_context.waiter = std::make_unique<Waiter>();
    -        thread_context.set_value(&g_thread_context);
             Lock lock(g_thread_context.waiter->m_mutex);
    +        thread_context.set_value(&g_thread_context);
             // Wait for shutdown signal from ProxyServer<Thread> destructor (signal
             // is just waiter getting set to null.)
             g_thread_context.waiter->wait(lock, [] { return !g_thread_context.waiter; });

    Fixing the thread init/destroy race by acquiring a lock one line earlier so the thread can't be used or destroyed until it's locked and ready for requests.

    An indirect fix would be to simply avoid creating and destroying a worker thread that is never used. It seems like run_deprecated_mining_test is the only test we have that is doing this. The problem can be avoided by not creating a ctx variable that is never used.

    --- a/test/functional/interface_ipc.py
    +++ b/test/functional/interface_ipc.py
    @@ -71,7 +71,9 @@ class IPCInterfaceTest(BitcoinTestFramework):
         def run_deprecated_mining_test(self):
             self.log.info("Running deprecated mining interface test")
             async def async_routine():
    -            ctx, init = await make_capnp_init_ctx(self)
    +            node = self.nodes[0]
    +            connection = await capnp.AsyncIoStream.create_unix_connection(node.ipc_socket_path)
    +            init = capnp.TwoPartyClient(connection).bootstrap().cast_as(self.capnp_modules['init'].Init)
                 self.log.debug("Calling deprecated makeMiningOld2 should raise an error")
                 try:
                     await init.makeMiningOld2()

    Either of these changes should fix the problem and probably both make sense, so I can open PRs for both.

  5. added a commit that references this issue on Mar 4, 2026
  6. achow101 commented on Mar 4, 2026

    @achow101
    Member

    Fixed by #34715

  7. added a commit that references this issue on Mar 11, 2026
  8. 13 remaining items

  9. added 2 commits that reference this issue on Mar 30, 2026
  10. added a commit that references this issue on May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions