<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/65074>65074</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[OpenMP] `#pragma omp distribute parallel for` causes segmentation fault
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Thyre
</td>
</tr>
</table>
<pre>
## Description
When using this very small test case, program execution crashes with `gdb` pointing to `kmp_sched.cpp`. Adding `teams` to the directive fixes the issue.
```c
int main(void)
{
#pragma omp distribute parallel for
for(int i = 0; i < 100; ++i)
{
}
return 0;
}
```
```console
$ clang --version
clang version 18.0.0 (https://github.com/llvm/llvm-project.git 4b383107fa7585bb5ecd7f03cab7800b33d1585a)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/software/software/LLVM/git/bin
$ clang -fopenmp reproducer.c
$ gdb ./a.out
[...]
(gdb) run
Starting program: /home/jreuter/tmp/Error/error_llvm_segfault_distribute/a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
__kmp_for_static_init<int> (loc=<optimized out>, global_tid=0, schedtype=34, pstride=<optimized out>, chunk=1, codeptr=0x5555555551e1 <main+113>, plastiter=<optimized out>, plower=<optimized out>, pupper=<optimized out>, incr=<optimized out>) at /home/jreuter/Projects/Compilers/llvm-project/openmp/runtime/src/kmp_sched.cpp:215
215 if (team->t.t_serialized) {
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVV-P4ygM_zTuC2pEIEnThz5Mp5PVSru6lWZv77Ei4CbsEkBA5s99-hNpp3Oz_3Q3GjVgG2Pzs38WMerBIu6g3kN9WIk5jS7sPo_PAVe9U887YBwYJweMMmiftLNAD0Bvzr9_jWjJHLUdSBp1JA8YnkmchDEkYUxEiojAbokPbghiIviEc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