https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108336
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Yes the race condition is the following: the order of calling random_number on which thread first. init_rand_state definitely takes a lock when reading/writing from/to master_state. I see no other race condition in the code. The code is in intrinsics/random.c https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgfortran/intrinsics/random.c;h=b5732e6c25a14359745c5f698c2dd4cab6f3c81f;hb=HEAD https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgfortran/intrinsics/random_init.f90;h=c2a6a0db9ee34c968494d1d2692ac4a48097251f;hb=HEAD