niall, gavin, thanks for your help. we successfully managed to eliminate the multiple copies of CGAL and boost::thread and the problem is gone. best, simon ________________________________________ From: Boost-users <boost-users-bounces@lists.boost.org> on behalf of Gavin Lambert <gavinl@compacsort.com> Sent: Tuesday, January 31, 2017 00:19 To: boost-users@lists.boost.org Subject: Re: [Boost-users] [thread] understanding multiple statically-linked boost::thread in same process On 28/01/2017 04:29, Simon Haegler wrote:
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" instanceof boost::thread is "more safe".
As Niall said, the general rules for library interaction are to not do that. You can sometimes get away with it if you're very careful about isolation -- in this case, it would probably work if you made sure that the thread_specific_ptrs are only ever accessed on threads that were started by the same library, and completely hid these threads from the consumers of the library -- but this way lies dragons, and it's far too easy to make seemingly simple changes that poke a hole in the isolation and break things, sometimes in subtle ways. So don't do it. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.boost.org_mailman_listinfo.cgi_boost-2Dusers&d=DwICAg&c=n6-cguzQvX_tUIrZOS_4Og&r=1qMgo39tVkx6cj8JVbCB5naHvVpKbYm8ncmOImpHPQY&m=t8Qx5jGJxvUNSoo53HQ3aW2Y8wpWRuwlLxye0SW6m9o&s=ILd1gLvij5UVuvlV9jPFNB3EY_CkzptDVgi_wfLpjJg&e=