From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14120 invoked by alias); 30 Dec 2012 19:57:51 -0000 Received: (qmail 13777 invoked by uid 48); 30 Dec 2012 19:57:26 -0000 From: "Joost.VandeVondele at mat dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/55561] TSAN: Fortran/OMP yields false positives Date: Sun, 30 Dec 2012 19:57:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: sanitizer X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: Joost.VandeVondele at mat dot ethz.ch X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-12/txt/msg02438.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55561 --- Comment #27 from Joost VandeVondele 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