PRUNERS / archer

Archer, a data race detection tool for large OpenMP applications
https://pruners.github.io/archer
Apache License 2.0
62 stars 13 forks source link

OpenMP inside pthread causes runtime SegF #41

Closed rolandschulz closed 7 years ago

rolandschulz commented 7 years ago

Given

#include <thread>
void f() {
    #pragma omp parallel
    {
    }
}
int main() {
    std::thread t1(f);
    std::thread t2(f);
    t1.join();
    t2.join();
}

And Archer (dc4e363) build with out of source with LLVM 4.0 and OMP-TR4 I get a runtime SegFault:

#0  0x00007ffff73a1bd0 in pthread_mutex_lock () from /lib64/libpthread.so.0
#1  0x000000000043979f in __interceptor_pthread_mutex_lock ()
    at /work/release-test/final/llvm.src/projects/compiler-rt/lib/tsan/../sanitizer_common/sanitizer_common_interceptors.inc:3672
#2  0x00007ffff7bccd43 in __gthread_mutex_lock(pthread_mutex_t*) () from /home/schulzro/tools/archer/lib/libarcher.so
#3  0x00007ffff7bccbe5 in std::mutex::lock() () from /home/schulzro/tools/archer/lib/libarcher.so
#4  0x00007ffff7bccb69 in DataPool<ParallelData, 4>::getData() () from /home/schulzro/tools/archer/lib/libarcher.so
jprotze commented 7 years ago

Roland, thanks for reporting this issue. The reason for your segfault is, that tool initialization for the created threads is skiped, because OMPT does not deliver any thread-creation callbacks.

I talked to OpenMP language advocates and they said, that OpenMP spec does not indicate that your program would be a valid OpenMP program (there is no notion of pthreads/C++11 threads in the spec).

Nevertheless, we are working with the OpenMP tools group to check whether the specification of OMPT is consistent with the OpenMP execution model. Since the OpenMP implementation supports your application behaviour, we think, that the OpenMP runtime should deliver a thread creation event.

Created an issue in the runtime repository: https://github.com/OpenMPToolsInterface/LLVM-openmp/issues/16