<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - Some Unity games fail assertion on startup in glXCreateContextAttribsARB"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=99781#c22">Comment # 22</a>
              on <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - Some Unity games fail assertion on startup in glXCreateContextAttribsARB"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=99781">bug 99781</a>
              from <span class="vcard"><a class="email" href="mailto:zegentzy@protonmail.com" title="Hal Gentz <zegentzy@protonmail.com>"> <span class="fn">Hal Gentz</span></a>
</span></b>
        <pre>Created <span class=""><a href="attachment.cgi?id=144685" name="attach_144685" title="Requested patch (does not work)">attachment 144685</a> <a href="attachment.cgi?id=144685&action=edit" title="Requested patch (does not work)">[details]</a></span> <a href='page.cgi?id=splinter.html&bug=99781&attachment=144685'>[review]</a>
Requested patch (does not work)

I tried implementing your suggested patch, Uli, but it did not work. 

XSync also tried to call LockDisplay, which for some reason blocks with our
call to LockDisplay. This behavior, I think, contradicts what the XLockDisplay
docs say: 

<span class="quote">>  Nested calls to XLockDisplay work correctly; the display will not actually be unlocked until XUnlockDisplay has been called the same number of times as XLockDisplay.</span >

This behavior really suprized me, so I'm not sure what's up. My only suspician
is that the mutex not being made with a call to pthread_mutex_init w/ the
PTHREAD_MUTEX_RECURSIVE attribute. I tried grepping for `pthread_mutex_init`,
`PTHREAD_MUTEX_RECURSIVE`, `pthread` and `RECURSIVE` in the libx11 codebase to
no avail. The only file I found was `UIThrStubs.c`, which if I understand
correctly, is only used when multi-threading support is disabled at compile
time.

I found a call to some `xmutex_init` function in locking.c, however, this
function only receives one parameter, unlike the two required by
`pthread_mutex_init`. gdb shows (I had to use `si` instead of `s`) that calls
to `xmutex_init` actually result in `pthread_mutex_init` getting called,
however, I'm not sure if that's because `xmutex_init` is some clever macro, or
if `-O3` inlined it. Nevertheless, I could not find any definition for
`xmutex_init` beyond the one in `UIThrStubs.c`.


I think we could possibly move the call to XSync after the call to
UnlockDisplay, however, I'm concerned that this might lead to some sort of race
condition if some other thread locking the display between our call to
UnlockDisplay and XSync's call to LockDisplay.</pre>
        </div>
      </p>


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

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