<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/54708>54708</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [OpenMP] Nondeterministic failures on Windows, x86
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          natgla
      </td>
    </tr>
</table>

<pre>
    [pf7.zip](https://github.com/llvm/llvm-project/files/8401036/pf7.zip)

Compile attached file with x86 clang/llvm 14.0.0 on Windows:

clang -O0 -fopenmp pf7.cpp

forever.cmd:
:start
a.exe
if "%errorlevel%" == "0" goto :start

run forever.cmd
in ~10 min it's crashing.

More details:
I've noticed the crash first when compiling this test with MSVC compiler:
cl  -Od  -openmp:llvm pf7.cpp /Zi
run in a loop, fails in ~ 10 min

libomp140.dll has debug info, the stack from there:

STACK_TEXT:  
0608ef58 5bcca66e     00000000 0608efc0 00000000 libomp140_i386!__kmp_wait_template<kmp_flag_64,1,0,1>+0x1f
0608efd4 5bcc9679     00000001 00000000 00000024 libomp140_i386!__kmp_hyper_barrier_release+0xbe
0608f020 5bcb719b     00000024 fffffffe 00cc2a00 libomp140_i386!__kmp_fork_barrier+0x1d9
0608f044 5bce67c7     00cc2a00 00000000 00000000 libomp140_i386!__kmp_launch_thread+0x3b
0608fb8c 763cfa29     00cc2a00 763cfa10 0608fbf8 libomp140_i386!__kmp_launch_worker+0x147
0608fb9c 77177a7e     00cc2a00 778ec5a0 00000000 kernel32!BaseThreadInitThunk+0x19
0608fbf8 77177a4e     ffffffff 77198a1b 00000000 ntdll!__RtlUserThreadStart+0x2f
0608fc08 00000000     5bce6680 00cc2a00 00000000 ntdll!_RtlUserThreadStart+0x1b

The test case has nested parallel region, everything else is irrelevant (I was able to crash it without pragma omp atomic, just takes longer). Let me know if you need more details


</pre>
<img width="1px" height="1px" alt="" src="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