[Bug libstdc++/77744] Data race on std::regex_iterator using openmp

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Sep 22 09:08:47 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77744

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #3)
> More importantly, the OpenMP version does not wait for the loop to finish
> (or at least, I see "#pragma omp for nowait" in the GIMPLE dump), so there
> is no happens-before relation between the loop body and the reTest
> destructor.

It does wait, the nowait there is just an optimization to avoid an unnecessary
extra barrier when there is one at the end of the parallel (the inital thread
doesn't continue until all other threads encountered the final barrier).

Current OpenMP (5.0+) allows lambdas, but we don't really know if there is any
race condition, as I said in #c5, tsan doesn't understand the libgomp barriers
and locking which are done using atomics and futexes, so in order to use
-fsanitize=thread together with libgomp the library needs to be built with
--disable-linux-futex, then it uses pthread_* APIs tsan understands.


More information about the Gcc-bugs mailing list