https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68718
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- omp_set/unset_lock of course is a memory barrier. All the problematic variables (it is not just busy, but also global_stack.top) are only modified when guarded with the lock, the problem is just read data races - those vars are read outside of the lock occassionally. libgomp itself (and other libraries) had such code quite often in the past, that has been changed a few years ago especially when ppc64 started to see issues, but also when -fsanitize=thread has been added. This testcase just needs the same treatment.