<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Assertion triggered when a serialized parallel region is after a detached task"
   href="https://bugs.llvm.org/show_bug.cgi?id=51258">51258</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Assertion triggered when a serialized parallel region is after a detached task
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>OpenMP
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Runtime Library
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>tianshilei1992@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The reproducer is every simple:
```
#include <omp.h>

int main(int argc, char *argv[]) {
#pragma omp parallel
  {
    omp_event_handle_t event;
    int a = 0;

#pragma omp task shared(a) detach(event)
    { a = 1; }

#pragma omp parallel
    { a = 2; }

#pragma omp taskwait
  }
  return 0;
}
```
Please ignore that the detached task is never fulfilled, because it is not the
point. If it is executed with env `OMP_NUM_THREADS=1`, then an assertion is
triggered.
```
Assertion failure at kmp_runtime.cpp(1114):
serial_team->t.t_task_team[this_thr->th.th_task_state] == __null.
OMP: Error #13: Assertion failure at kmp_runtime.cpp(1114).
OMP: Hint Please submit a bug report with this message, compile and run
commands used, and machine configuration info including native compiler and
operating system versions. Faster response will be obtained by including all
program sources. For information on submitting this issue, please see
<a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a>.
```
Basically, `__kmp_serialized_parallel` assumes that the corresponding task team
should be nullptr. However, if a detached task is encountered before, the task
team will be setup in `__kmp_task_alloc`.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>