From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8801 invoked by alias); 19 Nov 2013 17:51:55 -0000 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 Received: (qmail 5685 invoked by uid 48); 19 Nov 2013 17:49:53 -0000 From: "Joost.VandeVondele at mat dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug libgomp/59194] New: tsan detects race for real variables in an OMP reduction clause Date: Tue, 19 Nov 2013 17:51:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libgomp X-Bugzilla-Version: 4.9.0 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-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-11/txt/msg01886.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59194 Bug ID: 59194 Summary: tsan detects race for real variables in an OMP reduction clause Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgomp Assignee: unassigned at gcc dot gnu.org Reporter: Joost.VandeVondele at mat dot ethz.ch CC: jakub at gcc dot gnu.org This seems either a bug in libgomp or tsan, not clear which one. To reproduce, libgomp must be compiled first with -fsanitize=thread as described in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55561#c15 and the following workaround applied to get tsan to work with trunk. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59188#c3 The following program: > cat test.f90 INTEGER :: i REAL :: m m=0.0 !$OMP PARALLEL DO REDUCTION(+:m) DO i=1,10 m=m+1.0 ENDDO IF (m.NE.10.0) CALL ABORT() END compiled and executed as gfortran -g -fPIE -pie -fopenmp -fsanitize=thread test.f90 ; export OMP_NUM_THREADS=2 ; ./a.out triggers the error below. Interestingly, this only happens if 'm' is decleared REAL, not if INTEGER. ================== WARNING: ThreadSanitizer: data race (pid=13744) Atomic write of size 4 at 0x7fffc5e9bfa0 by main thread: #0 __tsan_atomic32_compare_exchange_strong ??:0 (libtsan.so.0+0x000000016da2) #1 MAIN__._omp_fn.0 test.f90:0 (exe+0x000000000ed1) #2 GOMP_parallel /data/vjoost/gnu/gcc_trunk/obj/x86_64-unknown-linux-gnu/libgomp/../../../gcc/libgomp/parallel.c:167 (libgomp.so.1+0x00000000e98c) #3 MAIN__ test.f90:0 (exe+0x000000000d73) #4 main ??:0 (exe+0x000000000df5) Previous read of size 4 at 0x7fffc5e9bfa0 by thread T1: #0 MAIN__._omp_fn.0 test.f90:0 (exe+0x000000000e9d) #1 gomp_thread_start /data/vjoost/gnu/gcc_trunk/obj/x86_64-unknown-linux-gnu/libgomp/../../../gcc/libgomp/team.c:117 (libgomp.so.1+0x000000014e40) Location is stack of main thread. Thread T1 (tid=13746, running) created by main thread at: #0 pthread_create /data/vjoost/gnu/gcc_trunk/obj/x86_64-unknown-linux-gnu/libsanitizer/tsan/../../../../gcc/libsanitizer/tsan/tsan_interceptors.cc:853 (libtsan.so.0+0x000000035b1a) #1 gomp_team_start /data/vjoost/gnu/gcc_trunk/obj/x86_64-unknown-linux-gnu/libgomp/../../../gcc/libgomp/team.c:795 (libgomp.so.1+0x000000015686) #2 GOMP_parallel /data/vjoost/gnu/gcc_trunk/obj/x86_64-unknown-linux-gnu/libgomp/../../../gcc/libgomp/parallel.c:166 (libgomp.so.1+0x00000000e987) #3 MAIN__ test.f90:0 (exe+0x000000000d73) #4 main ??:0 (exe+0x000000000df5) SUMMARY: ThreadSanitizer: data race ??:0 __tsan_atomic32_compare_exchange_strong ==================