<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 - GL_ARB_sync objects are not properly synchronized across threads"
href="https://bugs.freedesktop.org/show_bug.cgi?id=92757">92757</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>GL_ARB_sync objects are not properly synchronized across threads
</td>
</tr>
<tr>
<th>Product</th>
<td>Mesa
</td>
</tr>
<tr>
<th>Version</th>
<td>11.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Component</th>
<td>Mesa core
</td>
</tr>
<tr>
<th>Assignee</th>
<td>mesa-dev@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>sgunderson@bigfoot.com
</td>
</tr>
<tr>
<th>QA Contact</th>
<td>mesa-dev@lists.freedesktop.org
</td>
</tr></table>
<p>
<div>
<pre>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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the QA Contact for the bug.</li>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>