On 09/10/19 16:59 +0100, Jonathan Wakely wrote: >If two threads see _M_index==0 concurrently they will both try to set >it, potentially storing the facet at two different indices in the array. > >Either set the _M_index data member using an atomic compare-exchange >operation or while holding a mutex. > >Also move the LONG_DOUBLE_COMPAT code into a separate function to remove >the visual noise it creates. > > PR libstdc++/91057 > * src/c++98/locale.cc (locale::id::_M_id()) [__GTHREADS]: Use atomic > compare-exchange or double-checked lock to ensure only one thread sets > the _M_index variable. > [_GLIBCXX_LONG_DOUBLE_COMPAT]: Call find_ldbl_sync_facet to detect > facets that share another facet's ID. > [_GLIBCXX_LONG_DOUBLE_COMPAT] (find_ldbl_sync_facet): New function. > >Tested x86_64-linux, committed to trunk. That patch was broken on powerpc and other targets with long double compat symbols. Tested powerpc64le-linux, committed to trunk.