chriskohlhoff / asio

Asio C++ Library
http://think-async.com/Asio
4.72k stars 1.19k forks source link

ASIO_NO_TYPEID dynamic libraries crash #1403

Open boostiewj opened 6 months ago

boostiewj commented 6 months ago

In order to use the same asio source code for multiple dynamic libraries, ASIO_DYN_LINK and ASIO_NO_TYPEID are defined, and a crash occurs after use. After analyzing the code, we found that ASIO_NO_TYPEID cannot avoid having multiple static instances in multiple dynamic libraries. The code is as follows ` template static type_id_result_type type_id() {

if !defined(ASIO_NO_TYPEID)

return typeid(T);

else // !defined(ASIO_NO_TYPEID)

static int unique_id;
return &unique_id;

endif // !defined(ASIO_NO_TYPEID)

}`