Boost logo

Boost Users :

Subject: [Boost-users] [thread] understanding multiple statically-linked boost::thread in same process
From: Simon Haegler (SHaegler_at_[hidden])
Date: 2017-01-27 10:29:38


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://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_CGAL_cgal_blob_releases_CGAL-2D4.9_Filtered-5Fkernel_include_CGAL_Lazy.h-23L792&d=DwIFAw&c=n6-cguzQvX_tUIrZOS_4Og&r=gTL_yCLQl_7u2-yqgVXg0brOZdHvslFzcgXDiq_Zsb4&m=yj4lKAj11ftBa5Mw9t_dA9ja7LXtLliU9xCHesY3DhQ&s=59bluh0MtAaZJ3EXnqozwpQNY_re1ncp8Q559nsJYiw&e=

the definition of CGAL_STATIC_THREAD_LOCAL_VARIABLE is here?:

https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_CGAL_cgal_blob_releases_CGAL-2D4.9_Installation_include_CGAL_tss.h-23L38&d=DwIFAw&c=n6-cguzQvX_tUIrZOS_4Og&r=gTL_yCLQl_7u2-yqgVXg0brOZdHvslFzcgXDiq_Zsb4&m=yj4lKAj11ftBa5Mw9t_dA9ja7LXtLliU9xCHesY3DhQ&s=yX1td4vN_WehQasy76CR80NEszc9YoFAwKDJ7EBdNcM&e=

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_at_[hidden]


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net