https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #3) > Or do you mean it is possible that for two unrelated variables > variable 1 with its guard variable 2 with its guard > __cxa_guard_acquire succeeds > ctor is called > __cxa_guard_acquire succeeds > ctor is called > __cxa_guard_release is called > __cxa_atexit is called > __cxa_guard_release is called > __cxa_atexit is called > ? > I don't see how swapping __cxa_atexit and __cxa_guard_release would help, > __cxa_guard_acquire at least on most targets isn't a global synchronization > primitive that would serialize all local constructors, and making it > serializing would be very expensive. I think other threads running into an active init of another wait anyway (the init can fail), so they are in fact already serializing? Moving the cxa_atexit inside the guard would fix the race then.