http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55561



--- Comment #27 from Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> 
2012-12-30 19:57:24 UTC ---

(In reply to comment #24)

> For testing you can comment out first 2 lines of gomp_ptrlock_get(). That

> should fix the race in libgomp. It's not a good fix form performance pov, but

> should be OK for testing.



I found that the routines in config/posix can be used instead of the

config/linux by configuring gcc with '--disable-linux-futex' . With your

suggestion above, I still get warnings (absent in the linux case) from the

following testcase:



[vjoost@nanosim-s03 bugs]$ cat test_23.f90 

INTEGER :: i,j,OMP_GET_THREAD_NUM

!$OMP PARALLEL  PRIVATE(i,j)

j=OMP_GET_THREAD_NUM()

!$OMP DO

DO i=1,10

!$OMP CRITICAL(xxx)

!$OMP END CRITICAL(xxx)

! !$OMP CRITICAL(yyy)

! !$OMP END CRITICAL(yyy)

END DO

!$OMP END PARALLEL

END

[vjoost@nanosim-s03 bugs]$ gfortran -fsanitize=thread -fopenmp -gdwarf-3 -O1 

-fPIE -pie test_23.f90 

[vjoost@nanosim-s03 bugs]$ export OMP_NUM_THREADS=4 ; ./a.out

==================

WARNING: ThreadSanitizer: data race (pid=29039)

  Read of size 1 at 0x7d020003d050 by thread 1:

    #0 pthread_mutex_lock ??:0 (libtsan.so.0+0x00000001a863)

    #1 GOMP_critical_name_start

/data/vjoost/gnu/gcc_exp/obj/x86_64-unknown-linux-gnu/libgomp/../../../gcc/libgomp/config/posix/mutex.h:44

(libgomp.so.1+0x000000005e5d)

    #2 MAIN__._omp_fn.0 /data/vjoost/gnu/bugs/test_23.f90:6

(exe+0x000000000dcc)

    #3 gomp_thread_start

/data/vjoost/gnu/gcc_exp/obj/x86_64-unknown-linux-gnu/libgomp/../../../gcc/libgomp/team.c:116

(libgomp.so.1+0x00000000c6b2)



  Previous write of size 8 at 0x7d020003d050 by main thread:

    #0 gomp_barrier_wait_end

/data/vjoost/gnu/gcc_exp/obj/x86_64-unknown-linux-gnu/libgomp/../../../gcc/libgomp/config/posix/bar.c:93

(libgomp.so.1+0x00000000e691)

    #1 gomp_malloc

/data/vjoost/gnu/gcc_exp/obj/x86_64-unknown-linux-gnu/libgomp/../../../gcc/libgomp/alloc.c:36

(libgomp.so.1+0x000000005cba)

    #2 GOMP_critical_name_start

/data/vjoost/gnu/gcc_exp/obj/x86_64-unknown-linux-gnu/libgomp/../../../gcc/libgomp/critical.c:71

(libgomp.so.1+0x000000005e79)

    #3 MAIN__._omp_fn.0 /data/vjoost/gnu/bugs/test_23.f90:6

(exe+0x000000000dcc)

    #4 MAIN__ /data/vjoost/gnu/bugs/test_23.f90:2 (exe+0x000000000e43)

    #5 __libc_start_main ??:0 (libc.so.6+0x0037a121ecdc)



  Location is heap block of size 40 at 0x7d020003d050 allocated by main thread:

    #0 malloc ??:0 (libtsan.so.0+0x00000001839e)

    #1 gomp_malloc

/data/vjoost/gnu/gcc_exp/obj/x86_64-unknown-linux-gnu/libgomp/../../../gcc/libgomp/alloc.c:36

(libgomp.so.1+0x000000005cba)

    #2 GOMP_critical_name_start

/data/vjoost/gnu/gcc_exp/obj/x86_64-unknown-linux-gnu/libgomp/../../../gcc/libgomp/critical.c:71

(libgomp.so.1+0x000000005e79)

    #3 MAIN__._omp_fn.0 /data/vjoost/gnu/bugs/test_23.f90:6

(exe+0x000000000dcc)

    #4 MAIN__ /data/vjoost/gnu/bugs/test_23.f90:2 (exe+0x000000000e43)

    #5 __libc_start_main ??:0 (libc.so.6+0x0037a121ecdc)



  Thread 1 (tid=29040, running) created at:

    #0 pthread_create ??:0 (libtsan.so.0+0x00000001a298)

    #1 gomp_team_start

/data/vjoost/gnu/gcc_exp/obj/x86_64-unknown-linux-gnu/libgomp/../../../gcc/libgomp/team.c:440

(libgomp.so.1+0x00000000d000)

    #2 GOMP_parallel_start

/data/vjoost/gnu/gcc_exp/obj/x86_64-unknown-linux-gnu/libgomp/../../../gcc/libgomp/parallel.c:108

(libgomp.so.1+0x00000000abb7)

    #3 MAIN__ /data/vjoost/gnu/bugs/test_23.f90:2 (exe+0x000000000e39)

    #4 __libc_start_main ??:0 (libc.so.6+0x0037a121ecdc)



==================

ThreadSanitizer: reported 1 warnings

Reply via email to