Bug:Boost: Use shlibs instead of header-only for call_stack::top_

This symbol is defined as a static member object inside of a
boost detail header. When boost headers are used in a project
that uses Boost in both the main binary as well as dlopen()'d
shlibs, the top_ symbol gets duplicated and the metadata gets
partitioned.

We use the Boost shlib to unify both the main binary and the
shlibs to use the same memory address for top_.

This involves marking the templated object call_stack::top_ as
"extern" and then declaring to Boost that we intend to use the
shlibs.
This commit is contained in:
2025-11-03 22:18:45 -04:00
parent 6ea90c2dae
commit 5845f1a41d
22 changed files with 156 additions and 15 deletions
+25
View File
@@ -0,0 +1,25 @@
#ifndef BOOST_ASIO_LINKAGE_FIX_H
#define BOOST_ASIO_LINKAGE_FIX_H
#include <boost/asio/detail/call_stack.hpp>
#include <boost/asio/detail/thread_context.hpp>
#include <boost/asio/detail/tss_ptr.hpp>
namespace boost {
namespace asio {
namespace detail {
/** EXPLANATION:
* Extern declaration of the template instantiation
* This ensures that the .o translation units don't have their
* own copies of `call_stack<>::top_` defined in them.
*/
extern template
tss_ptr<call_stack<thread_context, thread_info_base>::context>
call_stack<thread_context, thread_info_base>::top_;
} // namespace detail
} // namespace asio
} // namespace boost
#endif // BOOST_ASIO_LINKAGE_FIX_H
+1
View File
@@ -1,6 +1,7 @@
#ifndef COMPONENT_THREAD_H
#define COMPONENT_THREAD_H
#include <boostAsioLinkageFix.h>
#include <atomic>
#include <thread>
#include <unordered_map>
@@ -1,6 +1,7 @@
#ifndef DEVICEREATTACHER_H
#define DEVICEREATTACHER_H
#include <boostAsioLinkageFix.h>
#include <atomic>
#include <memory>
#include <boost/asio/deadline_timer.hpp>