Boost logo

Boost :

Subject: [boost] [thread] 1.41.0 regression
From: Dmitry Goncharov (dgoncharov_at_[hidden])
Date: 2009-12-15 13:17:07


The thread_data_base constructor is defined in a header file. Function
make_external_thread_data() is defined in a .cpp file. This can lead to
a situation when different libraries contain the definitions of these
functions. The example below explains how this can happen and why this
causes problems.

The new version of struct thread_data_base contains an std::map member.
The size of an std::map object depends on if was
build with or w/o _GLIBCXX_DEBUG. contains make_external_thread_data(). This function
allocates an instance of thread_data_base. Due to an std::map member the
size of the allocated object depends on _GLIBCXX_DEBUG.

There is a library (e.g. which uses the Boost.Thread
library. Since the thread_data_base constructor is defined in a header
file can contain its definition.
Again, the size of thread_data_base object, that the thread_data_base
constructor from expects, depends on if was built
with _GLIBCXX_DEBUG defined or not.

An application cannot link agains both and
if these libraries were built with different _GLIBCXX_DEBUG definitions
(or different alignment, etc).
While loading the application the dynamic linker will use the definition
of thread_data_base constructor either from be or from Whichever it finds first.

Can both the thread_data_base constructor and
make_external_thread_data() reside either in a .cpp file or in a header?

BR, Dmitry

Boost list run by bdawes at, gregod at, cpdaniel at, john at