NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lib/51139: C++11 std::call_once() broken on NetBSD



The following reply was made to PR lib/51139; it has been noted by GNATS.

From: Kamil Rytarowski <n54%gmx.com@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: jwakely%redhat.com@localhost
Subject: Re: lib/51139: C++11 std::call_once() broken on NetBSD
Date: Wed, 21 Dec 2016 00:37:18 +0100

 This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
 --XIhW0cj4obWMxJ86tIQNMcewMATUxqHa1
 Content-Type: multipart/mixed; boundary="uiUp6R2bHkXWMUp2cN1Vx5amJkPTRURCQ"
 From: Kamil Rytarowski <n54%gmx.com@localhost>
 To: gnats-bugs%NetBSD.org@localhost
 Cc: jwakely%redhat.com@localhost
 Message-ID: <69cb1ee3-f006-3f11-e56a-2fdbcaac6580%gmx.com@localhost>
 Subject: Re: lib/51139: C++11 std::call_once() broken on NetBSD
 References: <pr-lib-51139%gnats.netbsd.org@localhost>
  <20160515010955.C351D7AAAE%mollari.NetBSD.org@localhost>
  <20160515160501.511577AAAE%mollari.NetBSD.org@localhost>
 In-Reply-To: <20160515160501.511577AAAE%mollari.NetBSD.org@localhost>
 
 --uiUp6R2bHkXWMUp2cN1Vx5amJkPTRURCQ
 Content-Type: text/plain; charset=windows-1252
 Content-Transfer-Encoding: quoted-printable
 
 On 15.05.2016 18:05, Joerg Sonnenberger wrote:
 > The following reply was made to PR lib/51139; it has been noted by GNAT=
 S.
 >=20
 > From: Joerg Sonnenberger <joerg%bec.de@localhost>
 > To: gnats-bugs%NetBSD.org@localhost
 > Cc: lib-bug-people%netbsd.org@localhost, gnats-admin%netbsd.org@localhost,
 > 	netbsd-bugs%netbsd.org@localhost
 > Subject: Re: lib/51139: C++11 std::call_once() broken on NetBSD
 > Date: Sun, 15 May 2016 18:03:17 +0200
 >=20
 >  On Sun, May 15, 2016 at 01:10:00AM +0000, n54%gmx.com@localhost wrote:
 >  > It happened that std::call_once() as defined in C++11 doesn't work i=
 n
 >  > 7.0 neither in HEAD (7.99.28).
 > =20
 >  Note that this issue is specific to libstdc++. libc++ works correctly.=
 
 > =20
 >  Joerg
 > =20
 >=20
 
 libc++ doesn't use pthread_once(3)
 
 The problem is with TLS used in combination with libstdc++ for
 std::call_once.
 
 Everything works (for single threaded setup safe) if we remove __thread
 from the following fragment:
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 #ifdef _GLIBCXX_HAVE_TLS
   __thread void* __once_callable;
   __thread void (*__once_call)();
 #else
   // Explicit instantiation due to -fno-implicit-instantiation.
   template class function<void()>;
   function<void()> __once_functor;
 
   mutex&
   __get_once_mutex()
   {
     static mutex once_mutex;
     return once_mutex;
   }
 
   // code linked against ABI 3.4.12 and later uses this
   void
   __set_once_functor_lock_ptr(unique_lock<mutex>* __ptr)
   {
     __get_once_functor_lock_ptr() =3D __ptr;
   }
 
   // unsafe - retained for compatibility with ABI 3.4.11
   unique_lock<mutex>&
   __get_once_functor_lock()
   {
     static unique_lock<mutex> once_functor_lock(__get_once_mutex(),
 defer_lock);
     return once_functor_lock;
   }
 #endif
 
   extern "C"
   {
     void __once_proxy()
     {
 #ifndef _GLIBCXX_HAVE_TLS
       function<void()> __once_call =3D std::move(__once_functor);
       if (unique_lock<mutex>* __lock =3D __get_once_functor_lock_ptr())
       {
         // caller is using new ABI and provided lock ptr
         __get_once_functor_lock_ptr() =3D 0;
         __lock->unlock();
       }
       else
         __get_once_functor_lock().unlock();  // global lock
 #endif
       __once_call();
     }
   }
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 
  --  src/external/gpl3/gcc/dist/libstdc++-v3/src/c++11/mutex.cc
 
 So far I have not reproduced this issue out of the libstdc++ context.
 Upstream reports that it might be related to ld.so and resolving
 __tls_get_addr, as it was causing trouble in the past.
 
 Perhaps something related:
 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D52192
 
 std::call_once is frequently used in LLDB.
 
 I've not reproduced this issue out of the libstdc++ context so far.
 
 
 --uiUp6R2bHkXWMUp2cN1Vx5amJkPTRURCQ--
 
 --XIhW0cj4obWMxJ86tIQNMcewMATUxqHa1
 Content-Type: application/pgp-signature; name="signature.asc"
 Content-Description: OpenPGP digital signature
 Content-Disposition: attachment; filename="signature.asc"
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIbBAEBCAAGBQJYWcC2AAoJEEuzCOmwLnZsPp4P93wns07DHZiVUr5DCGY6TAS1
 oMhUxlnq0is0Zz4CZ4W0Q6KkbUrHjxR4ifKb6aaWS7CUburlily3t6i8rBqgmanR
 tNH9gm2m+MjeDojkytyjrXP3vOVsAM8Rvw7WBudZURMTakijUiJ3nx/k5z6OLmcO
 KzOR0k/nzWYySZpNDJy37agR7otDUeogp9A4WXGJluHnXBFF2gbj1mq9Xd2+hMZx
 ViGZr5UOCjgp5obnxJWAYJ57SWfroNTbZOg+c5HRXBRSN73H9W9YvGWT5RdmQzhP
 Zgt+ekn4o3kKZ9O7cAoaxfYu2q+Eop5hD/G6hs+f7kiriXOiwIwUil1X8JQCymL/
 NnG30LDtzdIeDz+54LymZIhW5um4bI3hUpNVWd62RXlac/VKlji/7VJ7YX6rwmKh
 /Nlb3ASIc0guppUc2WcoXmOd2iGdPHT8dZzpjdMx+OPYsXzlfA0/BR8ivATtPkV3
 Dj83O/djNKekLVSCnxQoSGVnflVE9znAi00mqX6NzZvBQTvVKgFeRaphx50n+GlI
 7p16vy8NG5A93M+R0DrDFbRi9TYNjPDPEOaUG+9az0OB62DJWWkoNjTtrNDvs/QA
 RGHUoK8fz/PehhBGyD4x6kKxokxVqiAnDc2A6Qc9ZAFwctL5ESsC756gH21IIj4N
 78h4R5s0RW9JrWGUliA=
 =LUXc
 -----END PGP SIGNATURE-----
 
 --XIhW0cj4obWMxJ86tIQNMcewMATUxqHa1--
 


Home | Main Index | Thread Index | Old Index