<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 - Segfault when running nested parallels"
   href="https://bugs.llvm.org/show_bug.cgi?id=50519">50519</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Segfault when running nested parallels
          </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>Linux
          </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>rpenacob@bsc.es
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I've got a segfault when running the following code. It does not always fail
though.

int main() {
  int j_size = 20;
  int k_size = 20;
  #pragma omp parallel num_threads(4)
  {
    #pragma omp parallel num_threads(2)
    for(int j=0; j<j_size; j++){
      #pragma omp task
      for(int k=0; k<k_size; k++){
      } 
    } 
  } 
}

I've compiled with 59a4ee97288b commit with Debug.
To compile: clang -fopenmp t1.c -o t1
To execute:
  export OMP_MAX_ACTIVE_LEVELS=2
  for i in {0..100}; do ./t1 ; done

And I see one thread is freeing a team in
<a href="https://github.com/llvm/llvm-project/blob/main/openmp/runtime/src/kmp_runtime.cpp#L2496">https://github.com/llvm/llvm-project/blob/main/openmp/runtime/src/kmp_runtime.cpp#L2496</a>
that is being used by other thread in
<a href="https://github.com/llvm/llvm-project/blob/main/openmp/runtime/src/kmp_tasking.cpp#L2788">https://github.com/llvm/llvm-project/blob/main/openmp/runtime/src/kmp_tasking.cpp#L2788</a></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>