|
Boost : |
Subject: Re: [boost] [thread] 1.41.0 regression
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2009-12-16 05:48:33
Dmitry Goncharov <dgoncharov_at_[hidden]> writes:
> Anthony Williams wrote:
>> That won't make any difference. All the thread structures that are
>> defined in header files must have the same layout in the app as in the
>> thread library, otherwise you will either get linker errors or (worse)
>> runtime errors due to incorrect structure offsets.
>>
>>
> Agree.
>> The solution is to use the same compiler flags when you build your
>> application as when you build the boost thread library, to ensure that
>> the structures have the same layout.
>>
>>
> The same flags, etc are not feasible. Many users have their boost
> libraries prebuilt by the distromakers.
> When someone distributes a library which uses Boost.Thread the users
> have to build it with the same flags the Boost.Thread library was
> built. They don't know which flags Boost.Thread was built with.
>
> Having both the thread_data_base constructor and
> make_external_thread_data() reside either in a .cpp file or in a
> header eliminates the issue.
> Are there reasons not to?
This doesn't eliminate the issue, it just masks it. If the definition of
std::map varies depending on compiler settings then this will affect
more than just the constructor of thread_data_base. It will affect all
uses of thread_data_base, such as the derived classes created when a
boost::thread object is constructed to start a thread: the debug version
of std::map has additional members, so the layout of the derived classes
will be different depending on the setting of the macro.
If you wish to use the _GLIBCXX_DEBUG macro then you need to ensure that
your entire project, including any shared libraries that use Standard
C++ Library classes in their interface (such as boost.thread), are built
using that flag. Yes, that means you have to compile boost.thread from
source in this case, and can't use the system supplied one, but the same
applies to other shared libraries.
Anthony
-- Author of C++ Concurrency in Action http://www.stdthread.co.uk/book/ just::thread C++0x thread library http://www.stdthread.co.uk Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk