Re: [Boost-bugs] [Boost C++ Libraries] #10174: call_stack not working when building asio as shared module on windows

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #10174: call_stack not working when building asio as shared module on windows
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-11-19 00:25:56


#10174: call_stack not working when building asio as shared module on windows
-------------------------------+------------------------------
  Reporter: wberrier@… | Owner: chris_kohlhoff
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: asio
   Version: Boost 1.55.0 | Severity: Problem
Resolution: | Keywords: windows dispatch
-------------------------------+------------------------------

Comment (by anonymous):

 I have also seen related issues with 1.56.0 and 1.57.0 on Windows
 (mingw-w64) where boost::asio based code using strands is split across
 multiple implicitly-linked DLLs used by an exe, and BOOST_ASIO_HEADER_ONLY
 is defined for the build of all the DLLs and the exe.

 The call stack code does not appear to be working correctly and
 strand::running_in_this_thread() is not returning the correct result
 depending on the code path a thread takes through the various DLLs and
 which instance of top_ is being consulted.

 The same code (with each DLL replaced by an equivalent .so) appears to
 work fine on Linux.

 For anyone who comes across this ticket, my workaround that appears to be
 okay so far (as suggested by the bug reporter above) was to:
 * Use asio only with BOOST_ASIO_DYN_LINK defined (I'm using mingw, so
 BOOST_ASIO_SEPARATE_COMPILATION would probably be sufficient)
 * create a detail/call_stack.ipp file that contained the definition of the
 static templatised variable top_ (moved out of call_stack.hpp)
 * Add the usual pattern of #if defined (BOOST_ASIO_HEADER_ONLY) #include
 .../call_stack.ipp etc to the end of call_stack.hpp
 * Add call_stack.ipp to boost/asio/impl/src.hpp
 * #include <boost/asio/impl/src.hpp> once in a suitable source file that
 ends up in one DLL only, as per the usual boost separate compilation
 requirements.

 However, this led me to look through the rest of the asio code to see if
 the same pattern of both declaring _and_ defining a non-const static
 [templatised] variable in an hpp file is used elsewhere. At first glance,
 the same pattern is used in detail/winsock_init.hpp,
 detail/win_thread.hpp, and ssl/detail/openssl_init.hpp, and possibly
 elsewhere.

 Greater minds than I will need to decide if that code is also problematic
 in a multi-asio-using-DLL application on Windows and whether those
 definitions also need to be moved into the corresponding .ipp files for
 correct behaviour.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10174#comment:2>
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:17 UTC