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

    <tr>
        <th>Summary</th>
        <td>
            OpenMP runtime might try to take the bootstrap lock twice and deadlock
        </td>
    </tr>

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

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

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

<pre>
    This was initially reported here (including stacktraces): https://stackoverflow.com/questions/78183545/does-compiling-imagick-with-openmp-enabled-in-freebsd-13-2-cause-sched-yield

If `__kmp_register_library_startup` detects that another instance of the library is present, `__kmp_is_address_mapped` is eventually called. It calles `__kmp_str_format`, which uses `kmpc_alloc` to allocate memory for the string. This function calls `__kmp_entry_thread` to access the thread-local memory pool, which seems a bad idea during initialization. This macro internally calls `__kmp_get_global_thread_id_reg` which set the bootstrap look at the beginning (before calling `__kmp_register_library_startup`).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMk0GP4zYMhX-NciEcOEriOAcftl0E2EPRHno3aIm2uZElV6QnyP76wp5MZ4teekkEyvzeM-mHIjxEosacfzHnrztcdEy5-T7npD9o1yX_bP4cWeCBAhxZGUN4QqY5ZSUPI2UCY2uOLiye4wCi6O6a0ZEYezXHLzCqzmKOX4y9GXvb7tMb5T6kx96lydjbXwuJcopi7O1SH-rj-XQ29uYTSeHSNHPgOBQ84cDuXjxYxyLNFKe5oIhdIF9wLPpM1IkvDsfCFg4XoULcSL54MgVvyq-m_PL--60HU5Vte5_mNtPAopTbwF3G_GxFMesym6oET0pOBXREBYxJR8rAURSjI0g96Ejw6gMWmDMJRTX2108-S4veZxJpJ5xn8iuYBeiNoi7bMB2GQH4P3_T9KJ_dorntU55QTVWu3MfIboRF3h-6T7NrMYTkVqom2M6oBBNNKT-hT3kzKZo5DnvYVtkv0a3T3tR-EqOo-dnqmAn9B885EtkQ7_Vi5YcP_JxS-HQlRJMAQoce2BOCX1bVj8-Gf-Cq-jIxocsJOCrl-M8UfjIzkLZDSB2Gl6OW_bqs1diHnG7GupRUNOMMIaU74KtKA8e4yhtbd9SnTJvEVvkfyzf2ut_55uivxyvuqDlcDodTdamqy25sbO0dXbwnX3lbHvqS6vp6pdqXfY11hTtubGlP5dFWh_PpUFb7-kgH23XUU3mi2l_NqaQJOexDeJv2KQ87FlmoqauqPu0CdhRky6S1kR6wXRpr14jmZu0pumUQcyoDi8onRVkDNb_PFH_7A_ISlSeCiYdRQfNzXaninf4zN3cHfbAjwOjBE_q1tFtyaP4d3oF1XLpXalfR118x5_SdnBp726yuQd5e5e8AAAD__zH8hQQ">