Boost C++ Libraries: Ticket #11070: async_connect never calls back on mac with -fvisibility=hidden https://svn.boost.org/trac10/ticket/11070 <p> 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)". </p> <p> To test: </p> <pre class="wiki">mkdir build cd build cmake .. make ./main </pre><p> Result: The program never returns </p> <p> Expected: The program finishes (possibly with a "connection refused" error) </p> <p> 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. </p> <p> This code works if I comment the -fvisibility=hidden line in the CMakeLists.txt or if I comment the socket creation in main(). </p> <p> 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). </p> <p> 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&lt;T&gt; 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&lt;stream_socket_service&lt;ip::tcp&gt;&gt; and they are not merged at dynamic linking because the symbols are hidden. </p> <p> 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. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11070 Trac 1.4.3 blastrock Wed, 04 Mar 2015 14:54:44 GMT attachment set https://svn.boost.org/trac10/ticket/11070 https://svn.boost.org/trac10/ticket/11070 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">asiolock.tar.bz2</span> </li> </ul> <p> minimal code to reproduce </p> Ticket blastrock Wed, 04 Mar 2015 14:57:58 GMT attachment set https://svn.boost.org/trac10/ticket/11070 https://svn.boost.org/trac10/ticket/11070 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost-asio-socket-visibility.patch</span> </li> </ul> <p> possible fix to boost </p> Ticket blastrock Wed, 18 Mar 2015 16:21:07 GMT <link>https://svn.boost.org/trac10/ticket/11070#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11070#comment:1</guid> <description> <p> I found out this <a class="ext-link" href="http://stackoverflow.com/questions/19496643/using-clang-fvisibility-hidden-and-typeinfo-and-type-erasure"><span class="icon">​</span>http://stackoverflow.com/questions/19496643/using-clang-fvisibility-hidden-and-typeinfo-and-type-erasure</a> . It seems to be the exact problem that I saw here. It doesn't seem that it will be fixed in libc++, so something must be done in boost. </p> </description> <category>Ticket</category> </item> </channel> </rss>