<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/73104>73104</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang][OpenMP] Interaction of threadprivate variable with runtime calls in parallel region causes runtime exception
</td>
</tr>
<tr>
<th>Labels</th>
<td>
openmp,
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
NimishMishra
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
NimishMishra
</td>
</tr>
</table>
<pre>
The following reproducer causes a `RUNTIME_CHECK(length_ >= n) failed at /home/user1/.llvm/main/flang/runtime/buffer.h(165)`
```
program sample
implicit none
integer i
integer, parameter :: N = 8
integer :: M = 99
!$omp threadprivate (M)
!$omp parallel do copyin(M)
do i = 1, N
print *, "sample string"
stop 1
end do
!$omp end parallel do
end program sample
```
Note that should the copyin be removed, then the runtime failure is not observable. Moreover, enclosing the runtime calls in a critical section also causes the runtime failure to no longer be observed, hinting that maybe parallelization is the issue here.
```
do i = 1, N
!$omp critical
print *, "sample string"
stop 1
!$omp end critical
end do
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVF2PqzYQ_TXOy6gRHiCBBx72bhb1qkpaVbfPVwYG7MrYyDa53f76ysDuZnejqlJRhJT5njOHI7xXgyGqWP6FIV7UqLw8Ky-dYIgsP-3EHKR11a1n19juufomCXqrtf2hzACOJme7uSUHrZg9eRDADsnvf1y-fT0_fX_8-enxF4aFJjME-R1Y-sTSExiGJfRCaepABGBYSzsSw3r25DjDeq_1dWRYj0IZhnWvhRkY1m42QS2Bzdz35PaSYcEPOcOSHRKWnFjysL0PyfZb_k7ODk6M4MU4aVptAABqnLRqVQBjza3ZBBrIgfpkYvgIk3BipEAOWPrA0ge4QFyq-Jy_-c-LvyxvB4xhDDnDzI4TBOlIdJNTVxEIGBbnuNKdwNhba9LQWWjt9Bzh-RAcn86CWpryOPDlvXN5JqdMRP4hBjDEFRnwwakINd5J8cFOwN87yHTQ2XuTRs_NtGvIYrxziw_nWt8XGwiCFAG8tLPuIEjaloaGwNFor9TF-YMks3g3gizcmh2B8mBsANt4clfRaNrD2Tqy1_WSZFptfeTxbXIrtPagDAhonQqqFRo8tUFZA0J7-8L0ew2DBWNBWxPP39DWeZ1SKhPWXiLAKJ4begVI_S2W8mqtqryfCSQ52v8Lqf_7sd-u8rLQFvR_WfD-3B-K36HI6wa7rkq7Mi3Fjip-TJJDzlPkO1ll7ZGXnJKi74qC45FEVjY8yfsyTXlyLHaqwgRTzhE5T4qM7zMs8ixPBc-6rE_TlmUJjULpRUP21g27Bc7qmPIk22nRkPab7tmJzDjFPfGRIW4ys-ifq2L6T808eJYlWvng3woGFfSinWtGfmL5l18nMuffWH6CryaQEytfbP_h274KpyIR4YcK8jPlXr8YR0PM36j2Ekd_tTTFwrvZ6UqGMPmoMVgzrAcV5NzsWxuFc9PPZYfJ2T-pDQzrBQjPsF6w-CcAAP__bnfQpg">