Mesa (master): i965: Solve Android native fence fd double close

Chad Versace chadversary at kemper.freedesktop.org
Mon May 1 21:47:01 UTC 2017


Module: Mesa
Branch: master
Commit: 6f21b5601cc1260eac53f65c8941b3aa66d0f5e9
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6f21b5601cc1260eac53f65c8941b3aa66d0f5e9

Author: Randy Xu <randy.xu at intel.com>
Date:   Tue Apr 18 14:27:10 2017 +0800

i965: Solve Android native fence fd double close

The Android native fence in i965 has two fds: _EGLSync::SyncFd and
brw_fence::sync_fd.

The semantics of __DRI2fenceExtensionRec::create_fence_fd are unclear on
whether the DRI driver takes ownership of the incoming fd (which is the
same incoming fd from eglCreateSync).  i965 did take ownership, but all
other Mesa drivers do not; instead, they dup the incoming fd. As
a result, _EGLSync::SyncFd and brw_fence::sync_fd were the same fd, and
both egl_dri2 and i965 believed they owned it. On eglDestroySync, that
led to a double-close.

Fix the double-close by making brw_dri_create_fence_fd dup the incoming
fd, just like the other drivers do.

Signed-off-by: Randy Xu <randy.xu at intel.com>
Test: Run Vulkan and GLES stress test and no crash.
Fixes: 6403e376511 ("i965/sync: Implement fences based on Linux sync_file")
Reviewed-by: Emil Velikov <emil.velikov at collabora.com>
Reviewed-by: Chad Versace <chadversary at chromium.org>
[chadv: Polish the commit message]
Cc: mesa-stable at lists.freedesktop.org

---

 src/mesa/drivers/dri/i965/brw_sync.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_sync.c b/src/mesa/drivers/dri/i965/brw_sync.c
index 5b78503b34..a8356c304f 100644
--- a/src/mesa/drivers/dri/i965/brw_sync.c
+++ b/src/mesa/drivers/dri/i965/brw_sync.c
@@ -470,7 +470,7 @@ brw_dri_create_fence_fd(__DRIcontext *dri_ctx, int fd)
          goto fail;
    } else {
       /* Import the sync fd as an in-fence. */
-      fence->sync_fd = fd;
+      fence->sync_fd = dup(fd);
    }
 
    assert(fence->sync_fd != -1);




More information about the mesa-commit mailing list