Subject: [Boost-bugs] [Boost C++ Libraries] #11070: async_connect never calls back on mac with -fvisibility=hidden
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-03-04 14:50:25
#11070: async_connect never calls back on mac with -fvisibility=hidden
------------------------------+----------------------------
Reporter: blastrock | Owner: chris_kohlhoff
Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
Version: Boost 1.55.0 | Severity: Problem
Keywords: |
------------------------------+----------------------------
See the attached file for a minimal code to reproduce. I have tested this
on mac os yosemite with "Apple LLVM version 6.0 (clang-600.0.56) (based on
LLVM 3.5svn)".
To test:
{{{
mkdir build
cd build
cmake ..
make
./main
}}}
Result:
The program never returns
Expected:
The program finishes (possibly with a "connection refused" error)
What I do is to create a socket in the main binary (without using it) and
do an async_connect in a library with hidden symbols.
This code works if I comment the -fvisibility=hidden line in the
CMakeLists.txt or if I comment the socket creation in main().
This seems to be related to
boost::asio::detail::service_registry::keys_match which compares service
types. It relies on typeinfo to do that (unless BOOST_ASIO_NO_TYPEID is
set).
For that to work, typeid_wrapper is forced to default visibility (see
#pragma at boost/asio/detail/service_registry.hpp:32), but in recent mac
os versions it seems that it is not enough anymore. It seems that a symbol
Foo<T> is exported if and only if Foo AND T are set to default visibility.
So, in this case, we have two typeinfos for the same type
typeid_wrapper<stream_socket_service<ip::tcp>> and they are not merged at
dynamic linking because the symbols are hidden.
One possible fix is to set default visibility to stream_socket_service and
ip::tcp. This makes my example work, but it should be needed also for
other services and protocols as well. I have made a patch for for this,
but I don't know if this is the right way to fix it.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/11070> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:18 UTC