Boost logo

Boost :

From: Roland Schwarz (roland.schwarz_at_[hidden])
Date: 2007-11-16 02:40:26


David Deakins wrote:
> I have been testing the rewritten code for the thread library on one of
> our applications. On this project we create a Windows DLL that
> internally uses Boost.Thread to spawn worker threads. I noticed that
> when some applications make use of the DLL, access violations are
> generated in set_current_thread_data() in win32/thread.cpp.
> current_thread_data was resolving to an address of 0. After some
> investigation the source of the problem turned out to be that
> __declspec(thread) cannot be used in a DLL if the DLL might be loaded
> using LoadLibrary. Per the Microsoft 'Rules and Limitations for TLS',

Yes I know.
This is one of the reasons why the thread_specific_ptr uses TLSAlloc...
Family of functions. Also the mingw compiler crew decided to use these
API functions to implement __thread keyword.

Unfortunately Anthony did not contact me up-front on this matter, but
I am sure it will be easy enough for him to either change this to use
thread_specific_ptr or the TLSxxx family of functions.

@Anthony: are you listening?

Roland aka speedsnail


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk