------- 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