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
Prevent crash on unclean disconnect if abandoned IPC call returns interface pointer
This is a potential fix for bitcoin/bitcoin#34250
which reports that bitcoin node crashes if a rust stratrumv2 mining client
calls BlockTemplate.waitNext() and disconnects without waiting for a response
from the call, and if mempool fees increased so the call returns a non-null
interface BlockTemplate pointer.
The node would crash in this case while trying to call MakeProxyServer on the
returned BlockTemplate pointer, which would fail because MakeProxyServer would
try to use a reference to the Connection object that had been deleted as a as a
result of the disconnect.
The fix works by:
- Adding a Connection::m_canceler member variable and using it to cancel any
IPC response promises that are pending when the connection is destroyed.
- Updating type-context.h PassField() function to use promise.attach() as
described https://capnproto.org/cxxrpc.html#cancellation to detect
cancellation and set a ServerContext::m_cancelled variable.
- Updating ServerCall to check the ServerContext::m_cancelled status after any
C++ server method returns, and throw an exception if it is set.
- Updating type-context.h PassField() function to deal with the exception
by catching and logging it, and to deal with cancelled status by not
trying to fulfill the cancelled promise.
// Detect request being cancelled before or while it executes.
96
+
if (cancel_monitor.m_cancelled) MP_LOG(*server.m_context.loop, Log::Raise) << "IPC server request #" << req << " cancelled before it could be executed";
0 commit comments