Skip to content

Commit

Permalink
librados: workaround for boost::asio use of static member variables
Browse files Browse the repository at this point in the history
boost::asio uses static member variables in a header-only library to
provide thread local storage. When boost::asio is used in multiple
independent shared libraries (e.g. librados and librbd), each module
will have its own version of the static variables and therefore will
cause inconsistencies when attempting to access the data.

Under GNU ELF extensions, static member variables are given global
unique symbol visibility. This was broken in librados due to the
symbol map, so manually export the static member variables so that
the dynamic linker can properly consolidate the variables.

See github.com boostorg/asio issue 150

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
  • Loading branch information
Jason Dillaman committed Nov 16, 2020
1 parent 8d4a873 commit 29ee772
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ add_definitions(
-D_REENTRANT
-D_THREAD_SAFE
-D__STDC_FORMAT_MACROS
-D_FILE_OFFSET_BITS=64)
-D_FILE_OFFSET_BITS=64
-DBOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION)
if(LINUX)
add_definitions("-D_GNU_SOURCE")
endif()
Expand Down
10 changes: 10 additions & 0 deletions src/librados/librados.map
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
LIBRADOS_PRIVATE {
global:
extern "C++" {
"guard variable for boost::asio::detail::call_stack<boost::asio::detail::strand_executor_service::strand_impl, unsigned char>::top_";
"guard variable for boost::asio::detail::call_stack<boost::asio::detail::strand_service::strand_impl, unsigned char>::top_";
"guard variable for boost::asio::detail::call_stack<boost::asio::detail::thread_context, boost::asio::detail::thread_info_base>::top_";
"boost::asio::detail::call_stack<boost::asio::detail::strand_executor_service::strand_impl, unsigned char>::top_";
"boost::asio::detail::call_stack<boost::asio::detail::strand_service::strand_impl, unsigned char>::top_";
"boost::asio::detail::call_stack<boost::asio::detail::thread_context, boost::asio::detail::thread_info_base>::top_";

};
local: *;
};

Expand Down

0 comments on commit 29ee772

Please sign in to comment.