
Zitat von Edd Dawson <lists@mr-edd.co.uk>:
The bigger problem though, is that it might not be *their* old data. It can just as easily be someone else's old data due to coincidental alignment of different thread_specific_ptrs on the stack at entirely unrelated points in the program, or even in different libraries that each happen to use boost::thread_specific_ptr!
It's easy to see the problem here as the calls are very close to one another. In general, however, this strikes me as being really rather dangerous behaviour.
Would it be fair to call it a bug?
I have reported this bug here, including a simpler test case: https://svn.boost.org/trac/boost/ticket/3837 and posted a (more efficient) implementation of thread_specific_ptr which doesn't have this bug here: http://www.boostpro.com/vault/index.php?action=downloadfile&filename=tss.hpp&directory=& no reaction from the Boost.Thread maintainer so far. (it's a prototype: it only supports GCC so far, and IIRC I have fixed 1 or 2 bugs locally only, without uploading it. so be careful using it.)