This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libgomp/66553] New: openmp tasks produce libgomp warnings with fsanitize=thread


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66553

            Bug ID: 66553
           Summary: openmp tasks produce libgomp warnings with
                    fsanitize=thread
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgomp
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jtaylor.debian at googlemail dot com
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

when libgomp has been built with -fsanitize=thread works very well on programs
that do not use openmp tasks (just sections, parallel for etc.). There are no
false positives inside libgomp and it still nicely finds races in my code.

Unfortunately when using openmp tasks one gets warnings from libgomp itself
that (assuming they are only false positives) make it harder to find bugs in
the code one wants to instrument.
E.g. this simple example:

#include <stdio.h>
#include <omp.h>

int f(int i)
{
    printf("%d %d\n", omp_get_thread_num(), i);
    return i;
}

int main(int argc, const char *argv[])
{

#pragma omp parallel
#pragma omp single
    {
        for (size_t i = 0; i < 2; i++) {
#pragma omp task
            f(i);

        }
    }
    return 0;
}

when compiled with
$ gcc --version
gcc (GCC) 5.1.0
$ gcc tasks.c -fopenmp -fsanitize=thread

and run with a libgomp also compiled with sanitation, produces following
warning:

WARNING: ThreadSanitizer: data race (pid=11034)
  Write of size 4 at 0x7d6c0001f184 by main thread:
    #0 gomp_team_barrier_set_task_pending ../libgomp/config/linux/bar.h:135
(libgomp.so.1+0x000000013ad1)
    #1 GOMP_task ../libgomp/task.c:406 (libgomp.so.1+0x000000013ad1)
    #2 main._omp_fn.0 <null> (a.out+0x000000400b09)
    #3 GOMP_parallel ../libgomp/parallel.c:168 (libgomp.so.1+0x0000000101cc)
    #4 main <null> (a.out+0x000000400a80)

  Previous atomic read of size 4 at 0x7d6c0001f184 by thread T1:
    #0 __tsan_atomic32_load
../../../../libsanitizer/tsan/tsan_interface_atomic.cc:530
(libtsan.so.0+0x0000000591bc)
    #1 gomp_barrier_wait_final_start ../libgomp/config/linux/bar.h:115
(libgomp.so.1+0x00000001b558)
    #2 gomp_team_barrier_wait_final ../libgomp/config/linux/bar.c:133
(libgomp.so.1+0x00000001b558)
    #3 gomp_thread_start ../libgomp/team.c:119 (libgomp.so.1+0x000000016d14)

  Location is heap block of size 1712 at 0x7d6c0001f100 allocated by main
thread:
    #0 malloc ../../../../libsanitizer/tsan/tsan_interceptors.cc:491
(libtsan.so.0+0x0000000280d3)
    #1 gomp_malloc ../libgomp/alloc.c:37 (libgomp.so.1+0x00000000a11a)
    #2 gomp_new_team ../libgomp/team.c:149 (libgomp.so.1+0x000000016d6a)
    #3 GOMP_parallel ../libgomp/parallel.c:167 (libgomp.so.1+0x0000000101b3)
    #4 main <null> (a.out+0x000000400a80)

  Thread T1 (tid=11036, running) created by main thread at:
    #0 pthread_create ../../../../libsanitizer/tsan/tsan_interceptors.cc:895
(libtsan.so.0+0x000000029cc4)
    #1 gomp_team_start ../libgomp/team.c:796 (libgomp.so.1+0x00000001754e)
    #2 GOMP_parallel ../libgomp/parallel.c:167 (libgomp.so.1+0x0000000101c7)
    #3 main <null> (a.out+0x000000400a80)

SUMMARY: ThreadSanitizer: data race ../libgomp/config/linux/bar.h:135
gomp_team_barrier_set_task_pending

libgomp was built like this:
make CPPFLAGS='-fsanitize=thread' LDFLAGS='-fsanitize=thread' CC=gcc

Equivalent code not using tasks does not produce any warnings.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]