hi boost users,


i am debugging an application where several shared libraries contain statically-linked copies of boost::thread (and other boost components). this means the static part of boost::thread is multiple times present in the process.


on macos (apple clang 7.3) we see rare (but reproducible) access violations caused by boost::thread_specific_ptr::get() unexpectedly returning nullptr. if we enable assertions we get an assert in thread.cpp:151


if we dynamically link boost the problems go away. i can superficially understand that linking only one "common" instance of boost::thread is "more safe".


what could be the explanation for this observation? is this setup even supported? one theory is that the implementations in pthread/thread_heap_alloc.hpp interfere with each other...


the specific line where we get an unexpected nullptr (actually a bad reference) is here:

https://github.com/CGAL/cgal/blob/releases/CGAL-4.9/Filtered_kernel/include/CGAL/Lazy.h#L792


the definition of CGAL_STATIC_THREAD_LOCAL_VARIABLE is here​:

https://github.com/CGAL/cgal/blob/releases/CGAL-4.9/Installation/include/CGAL/tss.h#L38


boost version is 1.59


TIA,

simon


--
Simon Haegler | Software Engineer
Esri R&D Center Zurich | Foerrlibuckstrasse 110 | 8005 Zurich | Switzerland
T +41 44 204 60 80 | shaegler@esri.com