<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/76121>76121</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[OpenMP] [Flang] Program crashes at runtime with Segmentation fault when OMP PARALLEL DO IF(.false.) is encountered
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
chandankds
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
chandankds
</td>
</tr>
</table>
<pre>
Testcase to reproduce the issue.
```
PROGRAM parallel_do_if
USE OMP_LIB
INTEGER :: I
INTEGER :: N = 0
INTEGER, PARAMETER :: NI = 10
!$OMP PARALLEL DO IF(.false.)
DO I = 1, NI
END DO
!$OMP END PARALLEL DO
END PROGRAM
```
compile: flang-new -fopenmp ./test.f90 -o if.out
Run: ./if.out
Analysis: Segmentation fault is caused by null pointer dereference inside the __kmpc_fork_call_if function.
Triage: Issue introduced after https://github.com/llvm/llvm-project/pull/65436 . Testcase works as expected after removal of this patch.
Proposed Fix: Replace nullptr with struct of pointers to shared variables that aren't global
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVFFvozgQ_jXOy6gITAjJAw_pJawiNU2U7T1HgxnAV2Mj27Tbf38ypN3uqqfTSpEjZr75PPPxDeicbDVRwbJ7xrnoUNeon2vHOGfZboGj74wtfsYXlanfiidyXqAj8AYsDdbUoyDwHYF0bqSIxTsWb2_nKr79psfz5fTtsj3CgBaVInWtzVU2cw7g7-97OB3P14fD_Xvo8Pi0_7a_AEu3LN3C4T_ij8DSHcS_ZRn_C87by_a4f_oEPUzY5AZmPGF8eTqeJ-TDw_4Bdic4lIyvowaVo4jxDbwTh9RcHrgfP9rZP-5gd_qdMUQ_sc7pKTjL8KVEwvSDVBRabRTq9k7TK9w1ZiDdDxAxXnpyPmo2MdwZkE1kRj9XXkYdqgLkc3g-txrVm5MuIL5T25P26KXR0OCoPEgHAkdHNVRvoEelYDBSe7JQk6WGLGlBILWT9fyqr9fnfhDXxtjnq0ClrrKBZtQicP7igCcrsZ3GOQR3gNR-dkwN2IQLOu-H0BbjJeNlK303VpEwPeOlUi_vf3eDNf-Q8IyXw6gU4-UqW6YriODDjq_GPjtAB_RjIOE_LrDUmxdUYBrwnXQwoBfdLz2erRlMGL6UP0KnFxoUCpqEGLyFV-k7cN6OwgeWmzQuLIDr0FINL2glVooc-A49oCXNeO6hVaZCNd-yqIu03qQbXFCR5HGapPGa80VXLFNeJytR54jLNa14llX5ite4rvk63TR8IQse8zThPInTLF3yKM2rZo1pIvKlyPOsYsuYepQqClJFxraLaRWLfJXwZKGwIuVuWz6Z6rbgtpikrcbWsWWspPPuJ4OXXk2fhtNA-nhm2Q5Ydl9O5dkOzta0FnsQFl1HDtCDHbWXPc1yfWGy1440_N-qSQekhRmDwlQvRquKP3bINLxjvJzm_zcAAP__efqBCg">