mesa syncobj: don't store a pointer to the set_entry
authorJordan Justen <jordan.l.justen@intel.com>
Sat, 8 Dec 2012 20:43:10 +0000 (12:43 -0800)
committerJordan Justen <jordan.l.justen@intel.com>
Mon, 10 Dec 2012 18:58:45 +0000 (10:58 -0800)
The set_entry pointer can become invalid if the set table
is re-hashed.

This likely will fix
https://bugs.freedesktop.org/show_bug.cgi?id=58012
(Regression since 56e95d3c)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/main/mtypes.h
src/mesa/main/syncobj.c

index b353e7026f5f296f7d587ec0870c40747dcf5899..11a83228199eecc81cba223473c8f676dd495bbe 100644 (file)
@@ -2513,7 +2513,6 @@ struct gl_query_state
 /** Sync object state */
 struct gl_sync_object
 {
-   struct set_entry *SetEntry;
    GLenum Type;               /**< GL_SYNC_FENCE */
    GLuint Name;               /**< Fence name */
    GLint RefCount;            /**< Reference count */
index f599982bd9728c8a8bd7d88a731e9a6959c7dd4f..b977bfa214b0a08ce3e757d394ce64d06087a63a 100644 (file)
@@ -199,10 +199,16 @@ _mesa_ref_sync_object(struct gl_context *ctx, struct gl_sync_object *syncObj)
 void
 _mesa_unref_sync_object(struct gl_context *ctx, struct gl_sync_object *syncObj)
 {
+   struct set_entry *entry;
+
    _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
    syncObj->RefCount--;
    if (syncObj->RefCount == 0) {
-      _mesa_set_remove(ctx->Shared->SyncObjects, syncObj->SetEntry);
+      entry = _mesa_set_search(ctx->Shared->SyncObjects,
+                               _mesa_hash_pointer(syncObj),
+                               syncObj);
+      assert (entry != NULL);
+      _mesa_set_remove(ctx->Shared->SyncObjects, entry);
       _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
 
       ctx->Driver.DeleteSyncObject(ctx, syncObj);
@@ -290,9 +296,9 @@ _mesa_FenceSync(GLenum condition, GLbitfield flags)
       ctx->Driver.FenceSync(ctx, syncObj, condition, flags);
 
       _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
-      syncObj->SetEntry = _mesa_set_add(ctx->Shared->SyncObjects,
-                                        _mesa_hash_pointer(syncObj),
-                                        syncObj);
+      _mesa_set_add(ctx->Shared->SyncObjects,
+                    _mesa_hash_pointer(syncObj),
+                    syncObj);
       _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
 
       return (GLsync) syncObj;