You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Socket disconnect followed by segfault on macos/arm64 #191
I got some crashes testing bitcoin/bitcoin@37cd2c0 on macos/arm64. This is on a pruned mainnet node catching up on about 30 days behind blockchain tip. After these two crashes I wasn't able to reproduce any more for a little while after a few restarts then got the third crash.
error: timeout on transient error: kj::Exception: capnp/rpc.c++:2779: disconnected: Peer disconnected.
stack: 102cca3bc 102cc028c 1007be520 1007c0f90
Probably bitcoin-node is not running or not listening on a unix socket. Can be started with:
bitcoin-node -chain=main -ipcbind=unix
error: kj::Exception: capnp/rpc.c++:2779: disconnected: Peer disconnected.
stack: 1070523bc 10704828c 104f737c4 104f7621c
error: timeout on transient error: Could not connect to the server 127.0.0.1:8332
From these logs it seems like there are abrupt socket disconnects followed by segfaults and other errors here.
It seems like in the first example, the client is connecting and calling getbalance and then disconnecting before waiting for the getbalance response, and this causes the server to crash because it not handling the disconnect properly. The problem with abrupt disconnects causing crashes is known and should be fixed with bitcoin/bitcoin#32345. That PR should cause the server not crash in this case.
It is not clear what is causing the client to disconnect, though. And the client errors don't seem to make that much sense.
The first client error "timeout on transient error [...] Peer disconnected" only happens when the client is trying to connect to the server before it sends any RPC method request. So it does not seem consistent with the server log. Maybe it is actually from a different client than the one that send the getbalances request?
The second client error "null Own<> dereference" seems more promising. Maybe that is the client which sent the getbalances request, and suddenly crashed. If so, getting a stack trace from that client could reveal what the problem is.
The third client error "Could not connect to the server 127.0.0.1:8332" is actually an RPC error not an IPC error. But there is an IPC "Peer disconnected" error immediately before it, which I think would have to come from a different bitcoin-cli invocation? I don't see how a single bitcoin-cil invocation could result in both of these errors, since the first error should cause it to exit.
I guess overall I'm confused about some of this behavior, and also don't understand why there are multiple different client errors and only a single server error. Unclear if the server crashed different times with the same error, or if all of these clients were just to connecting to the same server around the time it crashed. [EDIT: rereading the OP it sounds like the server just crashed multiple times and the clients showed varying error messages each time it crashed]
I do think bitcoin/bitcoin#32345 should remove a lot of instability and noise here and make any remaining issues easier to resolve.
Actually I think I'm misreading the server logs and there might not even a sudden disconnect causing the server to crash. The two lines beginning the log could be a clean disconnect. The getbalances call after could be coming from another client if -getinfo calls are being made in succession. Could help to have more logs, or a stack trace from the server to clarify.
To be totally clear, I pummeled using watch ... -getinfo from 4 separate tmux panes, while sync was around 99%. I let that run for several minutes, then cancelled all the watch processes, took a breath, and executed one single -getinfo request -- for some reason that produced the same crash twice in lldb.
Thanks! The bitcoin-node stack trace is consistent with bugs fixed in #160 and bitcoin/bitcoin#32345. An annotated version of the stack trace shown below shows this is probably happening because the server.m_context.connection pointer is null, which would happen if the connection is closed suddenly before #160. If you merge into bitcoin/bitcoin#32345 into your branch, the server crash should stop happening.
It's still not clear what clients may be doing to trigger this crash though. If one of them is segfaulting before the server crash, that might explain this, and it could help to see the client stack trace. Otherwise it's not really clear. bitcoin/bitcoin#32345 might fix the client problems or might not, would have to test to find out.
Activity
ryanofsky commentedon Jul 24, 2025
From these logs it seems like there are abrupt socket disconnects followed by segfaults and other errors here.
It seems like in the first example, the client is connecting and calling
getbalanceand then disconnecting before waiting for thegetbalanceresponse, and this causes the server to crash because it not handling the disconnect properly. The problem with abrupt disconnects causing crashes is known and should be fixed with bitcoin/bitcoin#32345. That PR should cause the server not crash in this case.It is not clear what is causing the client to disconnect, though. And the client errors don't seem to make that much sense.
The first client error "timeout on transient error [...] Peer disconnected" only happens when the client is trying to connect to the server before it sends any RPC method request. So it does not seem consistent with the server log. Maybe it is actually from a different client than the one that send the
getbalancesrequest?The second client error "null Own<> dereference" seems more promising. Maybe that is the client which sent the
getbalancesrequest, and suddenly crashed. If so, getting a stack trace from that client could reveal what the problem is.The third client error "Could not connect to the server 127.0.0.1:8332" is actually an RPC error not an IPC error. But there is an IPC "Peer disconnected" error immediately before it, which I think would have to come from a different bitcoin-cli invocation? I don't see how a single bitcoin-cil invocation could result in both of these errors, since the first error should cause it to exit.
I guess overall I'm confused about some of this behavior, and also don't understand why there are multiple different client errors and only a single server error. Unclear if the server crashed different times with the same error, or if all of these clients were just to connecting to the same server around the time it crashed. [EDIT: rereading the OP it sounds like the server just crashed multiple times and the clients showed varying error messages each time it crashed]
I do think bitcoin/bitcoin#32345 should remove a lot of instability and noise here and make any remaining issues easier to resolve.
ryanofsky commentedon Jul 24, 2025
Actually I think I'm misreading the server logs and there might not even a sudden disconnect causing the server to crash. The two lines beginning the log could be a clean disconnect. The getbalances call after could be coming from another client if -getinfo calls are being made in succession. Could help to have more logs, or a stack trace from the server to clarify.
pinheadmz commentedon Jul 28, 2025
I was making many client calls to get the crashes, so that might explain why there seem to be multiple clients. I'll try to capture a stack.
pinheadmz commentedon Jul 28, 2025
Got something after pummeling with RPC requests:
pinheadmz commentedon Jul 28, 2025
To be totally clear, I pummeled using
watch ... -getinfofrom 4 separate tmux panes, while sync was around 99%. I let that run for several minutes, then cancelled all thewatchprocesses, took a breath, and executed one single-getinforequest -- for some reason that produced the same crash twice in lldb.ryanofsky commentedon Jul 28, 2025
Thanks! The
bitcoin-nodestack trace is consistent with bugs fixed in #160 and bitcoin/bitcoin#32345. An annotated version of the stack trace shown below shows this is probably happening because theserver.m_context.connectionpointer is null, which would happen if the connection is closed suddenly before #160. If you merge into bitcoin/bitcoin#32345 into your branch, the server crash should stop happening.It's still not clear what clients may be doing to trigger this crash though. If one of them is segfaulting before the server crash, that might explain this, and it could help to see the client stack trace. Otherwise it's not really clear. bitcoin/bitcoin#32345 might fix the client problems or might not, would have to test to find out.
Annotated stack trace from #191 (comment):
pinheadmz commentedon Aug 7, 2025
Couldn't reproduce the crash bitcoin/bitcoin#32345 so I think you can close this since the fixes seem to be merged already in libmultiprocess