public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgomp/59194] New: tsan detects race for real variables in an OMP reduction clause
@ 2013-11-19 17:51 Joost.VandeVondele at mat dot ethz.ch
  2013-11-19 18:25 ` [Bug libgomp/59194] " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Joost.VandeVondele at mat dot ethz.ch @ 2013-11-19 17:51 UTC (permalink / raw)
  To: gcc-bugs

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
==================


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-01-13 10:54 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-19 17:51 [Bug libgomp/59194] New: tsan detects race for real variables in an OMP reduction clause Joost.VandeVondele at mat dot ethz.ch
2013-11-19 18:25 ` [Bug libgomp/59194] " pinskia at gcc dot gnu.org
2013-11-19 18:46 ` Joost.VandeVondele at mat dot ethz.ch
2013-11-20 13:43 ` Joost.VandeVondele at mat dot ethz.ch
2013-11-20 13:51 ` jakub at gcc dot gnu.org
2013-11-20 17:26 ` Joost.VandeVondele at mat dot ethz.ch
2013-11-20 17:54 ` Joost.VandeVondele at mat dot ethz.ch
2013-11-20 17:59 ` jakub at gcc dot gnu.org
2013-11-20 18:12 ` Joost.VandeVondele at mat dot ethz.ch
2013-11-21 12:34 ` dvyukov at google dot com
2014-01-09 16:12 ` Joost.VandeVondele at mat dot ethz.ch
2014-01-13  7:57 ` jakub at gcc dot gnu.org
2014-01-13 10:54 ` Joost.VandeVondele at mat dot ethz.ch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).