Skip to content

Commit 350067f

Browse files
committed
Merge #121: ProxyClientBase: avoid static_cast to partially constructed object
5b81192 ProxyClientBase: avoid static_cast to partially constructed object (Ryan Ofsky) Pull request description: `ProxyClientBase` constructor was trying to call `ProxyClient::construct()` method before `ProxyClient` object had been fully constructed. This is causing a UBSAN error reported: - bitcoin/bitcoin#30975 (comment) - https://github.com/bitcoin/bitcoin/actions/runs/11970857809/job/33374462331?pr=30975 that looks like: ```c++ 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>' ``` ACKs for top commit: TheCharlatan: lgtm ACK 5b81192 Tree-SHA512: d96f728f30786f94c9792b8111580cec5c2a240721d123b433ee0cfa2b7bc17161048a5687158366c9a08b663334920001360ea41a60b6f856a4eec9f7e8185b
2 parents abe254b + 5b81192 commit 350067f

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)