[llvm-bugs] [Bug 44933] New: OpenMP target offload and Python regression because of exit handler order change

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Feb 16 11:53:32 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=44933

            Bug ID: 44933
           Summary: OpenMP target offload and Python regression because of
                    exit handler order change
           Product: OpenMP
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Runtime Library
          Assignee: unassignedbugs at nondot.org
          Reporter: csdaley at lbl.gov
                CC: llvm-bugs at lists.llvm.org

The following simple program segfaults with 10.0.0-rc2. I am running on a
system with Skylake CPUs and NVIDIA V100 GPUs.

+ cat demo.c
int cfunc(void)
{
  #pragma omp target
  {
    ;
  }
  return 123;
}
+ cat main.py
#!/usr/bin/env python
from ctypes import *
libdemo = CDLL("./libdemo.so")
rtn = libdemo.cfunc()
print "rtn value: ", rtn

+ clang -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -fPIC -shared -o
libdemo.so demo.c
+ srun -n 1 ./main.py

rtn value:  123
python:
/tmp/llvm-build.0qdn7s/llvm-project/openmp/libomptarget/src/rtl.cpp:339: void
RTLsTy::UnregisterLib(__tgt_bin_desc*): Assertion `R->isUsed && "Expecting used
RTLs."' failed.
srun: error: cgpu01: task 0: Aborted

This program works with LLVM/Clang trunk from Aug 28 2019. GDB shows that the
Python and LLVM OpenMP library exit handlers are now called in a different
order. Based on my installations of LLVM/Clang, I can tell that the change in
behavior happened sometime between Aug 28 2019 and Nov 09 2019.

10.0.0-rc2:
Thread 1 "python" hit Breakpoint 1, 0x00002aaaaaabb0e4 in _dl_fini () from
/lib64/ld-linux-x86-64.so.2
#0  0x00002aaaaaabb0e4 in _dl_fini () from /lib64/ld-linux-x86-64.so.2
#1  0x00002aaaab36cd78 in __run_exit_handlers () from /lib64/libc.so.6
#2  0x00002aaaab36cdca in exit () from /lib64/libc.so.6
#3  0x00002aaaab354f91 in __libc_start_main () from /lib64/libc.so.6

Thread 1 "python" hit Breakpoint 2, 0x00002aaaac9709f0 in
RTLsTy::UnregisterLib(__tgt_bin_desc*) () from
/project/projectdirs/m1759/csdaley/software/cgpu/llvm/10.0.0-rc2/lib/libomptarget.so
#0  0x00002aaaac9709f0 in RTLsTy::UnregisterLib(__tgt_bin_desc*) () from
/project/projectdirs/m1759/csdaley/software/cgpu/llvm/10.0.0-rc2/lib/libomptarget.so
#1  0x00002aaaac46089d in .omp_offloading.descriptor_unreg () from ./libdemo.so
#2  0x00002aaaaaabb2b3 in _dl_fini () from /lib64/ld-linux-x86-64.so.2
#3  0x00002aaaab36cd78 in __run_exit_handlers () from /lib64/libc.so.6
#4  0x00002aaaab36cdca in exit () from /lib64/libc.so.6
#5  0x00002aaaab354f91 in __libc_start_main () from /lib64/libc.so.6

Thread 1 "python" received signal SIGSEGV, Segmentation fault.


10.0.0 trunk from Aug 28:
Thread 1 "python" hit Breakpoint 2, 0x00002aaaac967c90 in
RTLsTy::UnregisterLib(__tgt_bin_desc*) () from
/usr/common/software/llvm/10.0.0-git_20190828/lib/libomptarget.so
#0  0x00002aaaac967c90 in RTLsTy::UnregisterLib(__tgt_bin_desc*) () from
/usr/common/software/llvm/10.0.0-git_20190828/lib/libomptarget.so
#1  0x00002aaaac460848 in .omp_offloading.descriptor_unreg () from ./libdemo.so
#2  0x00002aaaab36cd78 in __run_exit_handlers () from /lib64/libc.so.6
#3  0x00002aaaab36cdca in exit () from /lib64/libc.so.6
#4  0x00002aaaab354f91 in __libc_start_main () from /lib64/libc.so.6
[Thread 0x2aaab6210700 (LWP 70842) exited]

Thread 1 "python" hit Breakpoint 1, 0x00002aaaaaabb0e4 in _dl_fini () from
/lib64/ld-linux-x86-64.so.2
#0  0x00002aaaaaabb0e4 in _dl_fini () from /lib64/ld-linux-x86-64.so.2
#1  0x00002aaaab36cd78 in __run_exit_handlers () from /lib64/libc.so.6
#2  0x00002aaaab36cdca in exit () from /lib64/libc.so.6
#3  0x00002aaaab354f91 in __libc_start_main () from /lib64/libc.so.6
[Thread 0x2aaab600f700 (LWP 70841) exited]
[Inferior 1 (process 70825) exited normally]


The error does not happen if we compile demo.c without -fopenmp
-fopenmp-targets=nvptx64-nvidia-cuda compilation options.


Thanks,
Chris

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200216/baec522b/attachment.html>


More information about the llvm-bugs mailing list