This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/39909] non-TLS version of std::call_once causes terminate
- From: "jwakely dot gcc at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Apr 2009 17:40:37 -0000
- Subject: [Bug libstdc++/39909] non-TLS version of std::call_once causes terminate
- References: <bug-39909-5876@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from jwakely dot gcc at gmail dot com 2009-04-26 17:40 -------
Created an attachment (id=17707)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17707&action=view)
fix call_once without breaking ABI
Fix call_once to not use the global lock object, but retain the global for ABI
reasons.
__once_proxy detects if it was called by new code that provides the address of
a local lock object, or by old code that uses the global lock.
Without that check any uses of call_once inlined in old objects will be liable
to deadlock (because the global lock won't be unlocked before invoking the
functor) or segfaults (if the pointer is null when __once_proxy uses it).
Multiple concurrent calls to call_once from old object code will still
terminate, but it should be OK for new object code to use call_once freely, and
even for exactly one thread using the old call_once to run concurrently with
new code using call_once (because there would only be the single thread using
the global lock object.)
This patch adds the new symbols to the GLIBCXX_3.4.11 version but they should
be in a new 3.4.12 block - I don't know what I need to do for that.
Tested x86_64/linux --disable-tls
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39909