On 01/07/2020 21:53, Nikita Kniazev via Boost wrote:
I am informing release managers that there is a severe bug in Boost.Thread that will affect static library users built with MSVC in the next release. The bug report: https://github.com/boostorg/thread/issues/316 (TLDR: thread_specific_ptr data destructor is not called in non-Boost.Thread threads) I have opened a PR that fixes the issue https://github.com/boostorg/thread/pull/320, but got no response in weeks.
That entire part of Boost.Thread relies heavily on implementation specifics. Basically, it monkey patches the PE header of a DLL to intercept thread exit notifications to DllMain, and runs TLS cleanup for that thread. As of recent MSVCs, they have their own, much better, built-in system for thread local storage cleanup. You ought to use that instead. Of course, ideally speaking, Boost.Thread ought to gain understanding of recent MSVCs, and use the official TLS cleanup mechanism instead of monkey patching PE headers. I suspect you'll be waiting a long time for that though, and I recommend you just go ahead and refactor your code to use C++ 11 thread_local when on VS2017 or later. Niall