Skip to content

Commit 5b81192

Browse files
committed
ProxyClientBase: avoid static_cast to partially constructed object
ProxyClientBase constructor was trying to call ProxyClient::construct() method before ProxyClient object had been fully constructed yet. This was causing a UBSAN error reported: https://github.com/bitcoin/bitcoin/actions/runs/11970857809/job/33374462331?pr=30975 bitcoin/bitcoin#30975 (comment) that looked like: include/mp/proxy.h:95:45: runtime error: downcast of address 0x50600002bdc0 which does not point to an object of type 'ProxyClient<Interface>' (aka 'ProxyClient<ipc::capnp::messages::Init>') 0x50600002bdc0: note: object is of type 'mp::ProxyClientBase<ipc::capnp::messages::Init, interfaces::Init>'
1 parent abe254b commit 5b81192

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

include/mp/proxy-io.h

-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,6 @@ ProxyClientBase<Interface, Impl>::ProxyClientBase(typename Interface::Client cli
432432
});
433433
}
434434
});
435-
self().construct();
436435
}
437436

438437
template <typename Interface, typename Impl>

src/mp/gen.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,8 @@ void Generate(kj::StringPtr src_prefix,
357357
client << "public ProxyClientCustom<" << message_namespace << "::" << node_name << ", "
358358
<< proxied_class_type << ">\n{\n";
359359
client << "public:\n";
360-
client << " using ProxyClientCustom::ProxyClientCustom;\n";
360+
client << " template <typename... Args>\n";
361+
client << " ProxyClient(Args&&... args) : ProxyClientCustom(std::forward<Args>(args)...) { construct(); }\n";
361362
client << " ~ProxyClient();\n";
362363

363364
std::ostringstream server;

0 commit comments

Comments
 (0)