<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/65237>65237</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[OpenMP] crashing in libomptarget
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ye-luo
</td>
</tr>
</table>
<pre>
My llvm recipe
```
cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/soft/llvm/main-patched \
-DLLVM_ENABLE_BACKTRACES=ON \
-DLLVM_ENABLE_WERROR=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_TARGETS_TO_BUILD="X86;AMDGPU;NVPTX" \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_PROJECTS="clang;compiler-rt;lld" \
-DLIBOMPTARGET_ENABLE_DEBUG=ON \
../llvm-project/llvm
```
then build openmp using gcc (tested gcc9-12). The issue is not reproducible if openmp is built with clang.
```
cmake -DCMAKE_C_COMPILER=/soft/llvm/main-patched/bin/clang \
-DCMAKE_CXX_COMPILER=/soft/llvm/main-patched/bin/clang++ \
-DLLVM_ROOT=/soft/llvm/main-patched -DLIBOMPTARGET_ENABLE_DEBUG=ON \
-DCMAKE_INSTALL_PREFIX=/soft/llvm/main-patched ../llvm-project/openmp
```
Using this repdrodcer https://github.com/ye-luo/openmp-target/blob/master/tests/target_task/target_update_nowait_taskwait.cpp
```
clang++ -fopenmp -fopenmp-targets=x86_64-pc-linux-gnu -O3 target_nowait_taskwait.cpp && ./a.out
clang++ -fopenmp --offload-arch=gfx906 -O3 target_nowait_taskwait.cpp && ./a.out
clang++ -fopenmp --offload-arch=sm_86 -O3 target_nowait_taskwait.cpp && ./a.out
```
I got `Segmentation fault` or `illegal instruction` depending on the OS. It fails on SLES SP4 and Ubuntu 20.04 and 22.04.
Even if I built openmp with debugging flags. I still got `??` in the backtrace.
```
#1 0x00007ffff7b39ed8 in ?? () from /soft/llvm/main-patched/lib/libomptarget.so.18git
#2 0x00007ffff7b3c4a0 in ?? () from /soft/llvm/main-patched/lib/libomptarget.so.18git
#3 0x0000000000000000 in ?? ()
```
I also noticed changing `-O3` to `-O0` makes the test run.
So I'm wondering if there is some potential bug in the tasking runtime as the segfault happens when running the `update from nowait` target task.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0Vl1zmzgU_TXyyx0YkGxsP_jBjnGXrR08hnSzTx4BArQVEoNEk_77HYGT5sNtp51pxkMQupxzde_REVRrXknGVmi2QbPthPamVt3qK3NEryaZKr6uDl9BiC8NdCznLUPeFnlrFHiX3zDMG_qZgbO9Oaw_hueb8018OEb78ITItsrzbxP396-mEN4gvAE0uxlhngM3d9F-e07_PYaIbE9MMKrZlbDoNknX-_35eAp30T0iW4R3WpUG4Z3NGOFdQ7l0WmrymhWvAPb7T4dzeLve7MPzZn3zMT2tb8IEkW18-yIO4E3oP-HpFNvc493uFd6YcfLX-hRuz_tok7yLeYd1StPoLeElIl2fPoRpck7jsRTD0vD9IkBksz5sPxzvENncfjqm9wjj765rnSThKY3i23freh13PMV_hzdpMrLkgsoKkU2umpYL1jmdQWQjRPGOKtrEh-OY6hPUNtzcfbhSRde99MRpO_Ufy59bdE1NpmYSsp6LAlTLZNNCr7mswEoJ4YVh2rDCjpaOjxFeupDWDLjWvb2CVAY61naq6HOeCQa8fMLhesA18MBNDcNK3V8V9A81hvAu4xLh3YB9RbJvtsAvgF3ZLEMTT3Gc_lT6v9Ct39xc1zo8Vv1qgcfr3dBXU3NtO1Z0qshZB7UxrUZkjfAO4V3FTd1nbq4s5ehLz9COoV3FLFUmVDakpA3rEN5ZkWj7fwg4G6o_fxv1bUENO0v1QPk4Z2_cvL2e68vyO-VFSk83lxQ0ItvHRXAOp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