[Mesa-dev] [Bug 92757] GL_ARB_sync objects are not properly synchronized across threads

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Sat Oct 31 12:04:18 PDT 2015


https://bugs.freedesktop.org/show_bug.cgi?id=92757

            Bug ID: 92757
           Summary: GL_ARB_sync objects are not properly synchronized
                    across threads
           Product: Mesa
           Version: 11.0
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: medium
         Component: Mesa core
          Assignee: mesa-dev at lists.freedesktop.org
          Reporter: sgunderson at bigfoot.com
        QA Contact: mesa-dev at lists.freedesktop.org

Hi,

I have a program which uses multiple threads, with separate but shared
contexts. To synchronize data between them, I use fences (from GL_ARB_sync).
I've had issues with that occasionally, perhaps every 50000th frame, or so,
glWaitSync() would return GL_INVALID_OPERATION (0x501) on a sync object, even
though it's supposed to be completely legal.

Looking into src/mesa/main/syncobj.c sheds some light on what the issue might
be. It seems many operations are not properly locked at all; in particular,
_mesa_validate_sync() is repeatedly called without any locks held, yet looks
into a hashtable in ctx->Shared (that is modified by other threads, although
those threads hold the lock).

Just adding a lock to _mesa_validate_sync() would seem not to be enough,
though. In particular, you have functions like _mesa_ClientWaitSync() which
does _mesa_validate_sync(), does some other work and only then calls
_mesa_ref_sync_object(); another thread could have deleted the object between
validation and ref. And finally, even within the ref/unref pair, there's
checking of various state without any locking, which probably needs some
thought to verify that it's actually fine if another thread should be modifying
the sync object in the meantime.

Perhaps the best thing to do would just be to lock ctx->Shared whenever dealing
with a sync object, but one would have to make sure e.g. glClientWaitSync()
doesn't sleep while keeping that lock.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20151031/5a13e8e8/attachment.html>


More information about the mesa-dev mailing list