<html>
    <head>
      <base href="https://bugs.freedesktop.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 - Hang when using glWaitSync with multithreaded shared GL contexts"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=111784">111784</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Hang when using glWaitSync with multithreaded shared GL contexts
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>DRI
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>XOrg git
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>x86-64 (AMD64)
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux (All)
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>not set
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>DRM/AMDgpu
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>dri-devel@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>emmanueldurand@protonmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=145472" name="attach_145472" title="Output of dmesg">attachment 145472</a> <a href="attachment.cgi?id=145472&action=edit" title="Output of dmesg">[details]</a></span>
Output of dmesg

I develop a tool which uses a separate thread for uploading textures to the
GPU, in parallel to the rendering thread. These two threads are synchronized
using OpenGL fences, which prevents the rendering to happen while a texture is
being copied from a PBO.

On recent AMD hardware (tested on a Vega 56 and a Radeon VII) this setup hangs
almost instantaneously. From my tests it seems that it waits for a glWaitSync
to finish. The exact same code runs flawlessly on Intel (Mesa driver) and
Nvidia (proprietary driver).

I managed to somewhat reproduce the issue in a simpler code, which merely
creates two shared OpenGL contexts and does nothing except creating fences and
waiting for the other thread. This example hangs with AMDGPU driver, but once
again runs fine on Intel (Mesa driver) and Nvidia (proprietary driver).

I'll attach the code to this thread, and it can be found here too:
<a href="https://gitlab.com/sat-metalab/splash/blob/fix/radeon_test/tests/sandbox/radeon_mesa_shared_context_freeze.cpp">https://gitlab.com/sat-metalab/splash/blob/fix/radeon_test/tests/sandbox/radeon_mesa_shared_context_freeze.cpp</a>.</pre>
        </div>
      </p>


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

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>