https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109889
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I wonder if we have a static destructor ordering problem.
The libstdc++ test code uses a local static std::map, which will be
constructed on first use and destroyed on exit. When built with
-D_GLIBCXX_DEBUG that is a __gnu_debug::map which uses checked iterators, so
keeps a list of all constructed iterators. On destruction that map locks a
mutex, which is another local static, and .
Since r13-6282-gd70f49e98245f8 the mutexes are created in a char buffer and
never destroyed:
// Use a static buffer, so that the mutexes are not destructed
// before potential users (or at all)
static __attribute__ ((aligned(__alignof__(M))))
char buffer[(sizeof (M)) * (mask + 1)];
static M *m = new (buffer) M[mask + 1];
return m[i];
But something could be wrong with lifetimes of those statics, causing an
invalid 'this' pointer to be used somewhere.