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

    <tr>
        <th>Summary</th>
        <td>
            OpenMP: Extra barrier policy debug assert hit
        </td>
    </tr>

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

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

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

<pre>
    ```cpp
int main()
{
  #pragma omp parallel num_threads(32)
  {
      #pragma omp task
      {
 }
      #pragma omp taskwait
  }
}
```
`clang -fopenmp t1.c -o t1 && KMP_TASKING=1 ./t1`
I've been playing with `tskm_extra_barrier` tasking mode and got an `Assertion failure at kmp_tasking.cpp(3392): *unfinished_threads >= 0.`

With gdb I see `*unfinished_threads == -1`. I think this happens because there is the assumption `tt_unfinished_threads` is the number of threads of the team when running `execute_tasks`. With extra_barrier tasking mode this is not respected because execute_tasks is run both in `__kmp_tasking_barrier` and `__kmp_wait_template` of the barrier.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8U01v4zYQ_TXUZWCBor6cgw5eeF0Ei20DtECPAimNJdYUSZCjzebfF1RsJ0bRNQxqpJk3fO8NKWPUk0XsWP2F1cdMrjS70C36It1Lptz41rGGv_8H7xk_Mn7QlmCR2jKxZ-Lp_Rtrv7wHAEyUPshpkeAWD14GaQwasOvS0xxQjpGJfSnuUIBP4PR7bEAyXh6y92LWHn8Ne5WaPvY43pjegpuw--tgpJ1gd3YebWpR5APsHFABTDRMNPDt-0v_1-HPb8-__8bKYwE5Eycq7i2emWh_IChEC97IN20neNU0A2s4xcvS408KslcyBI2BNXxjmaoWNyJIO8LkCKRNgEOMGEg7C2epzRoQJMFl8f0Vk6d5iH1ZPm1Wlgdg4rDas7Y6zjjevAZWfmXlEXj-oXRb_07EplHBM0TEtOP_4Y8Jv0syc3gGmrW9pDXCLL1HG0HhINeIQDMGBB1TADLGdfGbgCSf-v_2Tg5cq-26KAzgznDbdwsRCOUCrzNaCKu1ySvWcPyJw0q4WRE3XpuaB3sfvd346gjWEQSMHgfC8U78oV8qC6sF5WgGvbHv-0_Gf55fGtk9n45bT7h4IwlT9irhWp9nY1eOT-WTzLArWl7t96Kp6mzuxqYp-b4aOTb8rGrRjuW-qYSqioE3qj1nuhNcVLwoeMFLXtW5UnVRiXoc8FyJqh5YxXGR2uTG_FhyF6ZMx7hi17Z1W2dGKjRxu-NCWHyFLcmESFc-dAmzU-sUWcWNjhQ_upAmg90fHu33l3TEviaHb4LAO6OHNxhRrVOaNwaCWVO2BtPNRD6y8sDEiYnTpGleVT64hYlT6n597Hxw_-BATJw2TpGJ08b53wAAAP__GqNzcQ">