Helgrind用OpenMP报告最简单的C++代码的“可能的数据竞争”

Helgrind用OpenMP报告最简单的C++代码的“可能的数据竞争”,c++,openmp,valgrind,C++,Openmp,Valgrind,我正在检查我的程序的线程错误,并通过使用以下最简单的代码再现了helgrind错误: int main() { int num = 24; #pragma omp parallel for firstprivate(num) for (int i= 0; i <num; ++i) { int test = 0; } } 可能重复的请参见上述注释中的问题,Helgrind by fault不适用于GNU OpenMP,它必须以特殊方式编译。 1

我正在检查我的程序的线程错误,并通过使用以下最简单的代码再现了helgrind错误:

int main() {

int num = 24;
#pragma omp parallel for firstprivate(num)
    for (int i= 0; i <num; ++i) {
        int test = 0;
    }
}

可能重复的请参见上述注释中的问题,Helgrind by fault不适用于GNU OpenMP,它必须以特殊方式编译。
  1     ==11990== Helgrind, a thread error detector
  2     ==11990== Copyright (C) 2007-2013, and GNU GPL'd, by OpenWorks LLP et al.
  3     ==11990== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
  4     ==11990== Command: /home/windenergy/test
  5     ==11990== Parent PID: 10832
  6     ==11990==
  7
  8     parse_type_DIE: confused by:
  9      <2><197>: DW_TAG_typedef
 10          DW_AT_type        : <1f4>
 11
 12     --11990-- WARNING: Serious error when reading debug info
 13     --11990-- When reading debug info from /home/windenergy/test:
 14     --11990-- parse_type_DIE: confused by the above DIE
 15     ==11990== ---Thread-Announcement------------------------------------------
 16     ==11990==
 17     ==11990== Thread #1 is the program's root thread
 18     ==11990==
 19     ==11990== ---Thread-Announcement------------------------------------------
 20     ==11990==
 21     ==11990== Thread #24 was created
 22     ==11990==    at 0x5ACE05E: clone (in /lib64/libc-2.11.3.so)
 23     ==11990==    by 0x57DC990: do_clone (in /lib64/libpthread-2.11.3.so)
 24     ==11990==    by 0x57DCF77: pthread_create@@GLIBC_2.2.5 (in /lib64/libpthread-2.11.3.so)
 25     ==11990==    by 0x4C2DB78: pthread_create_WRK (hg_intercepts.c:269)
 26     ==11990==    by 0x4C2DC89: pthread_create@* (hg_intercepts.c:300)
 27     ==11990==    by 0x53BA56D: ??? (in /usr/lib64/libgomp.so.1.0.0)
 28     ==11990==    by 0x400816: main (test.cpp:4)
 29     ==11990==
 30     ==11990== ----------------------------------------------------------------
 31     ==11990==
 32     ==11990== Possible data race during write of size 4 at 0x5F750C0 by thread #1
 33     ==11990== Locks held: none
 34     ==11990==    at 0x53BB85B: ??? (in /usr/lib64/libgomp.so.1.0.0)
 35     ==11990==    by 0x53BA5B0: ??? (in /usr/lib64/libgomp.so.1.0.0)
 36     ==11990==    by 0x400816: main (test.cpp:4)
 37     ==11990==
 38     ==11990== This conflicts with a previous read of size 4 by thread #24
 39     ==11990== Locks held: none
 40     ==11990==    at 0x53BB8C6: ??? (in /usr/lib64/libgomp.so.1.0.0)
 41     ==11990==    by 0x53BA0B8: ??? (in /usr/lib64/libgomp.so.1.0.0)
 42     ==11990==    by 0x4C2DD12: mythread_wrapper (hg_intercepts.c:233)
 43     ==11990==    by 0x57DD7F5: start_thread (in /lib64/libpthread-2.11.3.so)
 44     ==11990==    by 0x5ACE09C: clone (in /lib64/libc-2.11.3.so)
 45     ==11990==
 46     ==11990== Address 0x5F750C0 is 128 bytes inside a block of size 192 alloc'd
 47     ==11990==    at 0x4C2819E: malloc (vg_replace_malloc.c:291)
 48     ==11990==    by 0x53B6038: ??? (in /usr/lib64/libgomp.so.1.0.0)
 49     ==11990==    by 0x53BA7DF: ??? (in /usr/lib64/libgomp.so.1.0.0)
 50     ==11990==    by 0x400816: main (test.cpp:4)
 51     ==11990==
 52     ==11990== ----------------------------------------------------------------
 53     ==11990==
 54     ==11990== Possible data race during write of size 4 at 0x5F75084 by thread #1
 55     ==11990== Locks held: none
 56     ==11990==    at 0x53BB869: ??? (in /usr/lib64/libgomp.so.1.0.0)
 57     ==11990==    by 0x53BA5B0: ??? (in /usr/lib64/libgomp.so.1.0.0)
 58     ==11990==    by 0x400816: main (test.cpp:4)
 59     ==11990==
 60     ==11990== This conflicts with a previous read of size 4 by thread #24
 61     ==11990== Locks held: none
 62     ==11990==    at 0x53BB8C0: ??? (in /usr/lib64/libgomp.so.1.0.0)
 63     ==11990==    by 0x53BA0B8: ??? (in /usr/lib64/libgomp.so.1.0.0)
 64     ==11990==    by 0x4C2DD12: mythread_wrapper (hg_intercepts.c:233)
 65     ==11990==    by 0x57DD7F5: start_thread (in /lib64/libpthread-2.11.3.so)
 66     ==11990==    by 0x5ACE09C: clone (in /lib64/libc-2.11.3.so)
 67     ==11990==
 68     ==11990== Address 0x5F75084 is 68 bytes inside a block of size 192 alloc'd
 69     ==11990==    at 0x4C2819E: malloc (vg_replace_malloc.c:291)
 70     ==11990==    by 0x53B6038: ??? (in /usr/lib64/libgomp.so.1.0.0)
 71     ==11990==    by 0x53BA7DF: ??? (in /usr/lib64/libgomp.so.1.0.0)
 72     ==11990==    by 0x400816: main (test.cpp:4)
 73     ==11990==