summaryrefslogtreecommitdiffstats
path: root/src/hardwareintegration
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@qt.io>2019-03-26 14:25:51 +0100
committerPaul Olav Tvete <paul.tvete@qt.io>2019-03-27 09:16:58 +0000
commitfde6362edc6ecadbcca8872f71c111bd7c896801 (patch)
tree3fc0d10e556f4fc33db93ac91d9d926480510153 /src/hardwareintegration
parent19361e7259f04b08925b1e8e99faf9460770ee7b (diff)
Vulkan server buffer integration crash fix
Duplicate file descriptor before calling glImportMemoryFdEXT() on the server side. The Khronos specification says that "performing any operation on <fd> in the application after an import results in undefined behavior". Change-Id: I6a800171450578b1dabba7efc624623388acf3a1 Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Diffstat (limited to 'src/hardwareintegration')
-rw-r--r--src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp b/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp
index 46e335728..df197ca23 100644
--- a/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp
+++ b/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp
@@ -46,6 +46,9 @@
#include <QtGui/QOffscreenSurface>
#include <QtGui/qopengl.h>
+#include <unistd.h>
+#include <fcntl.h>
+
#include <QtCore/QDebug>
QT_BEGIN_NAMESPACE
@@ -213,7 +216,15 @@ QOpenGLTexture *VulkanServerBuffer::toOpenGlTexture()
funcs->glCreateMemoryObjectsEXT(1, &m_memoryObject);
if (extraDebug) qDebug() << "glCreateMemoryObjectsEXT" << hex << glGetError();
- funcs->glImportMemoryFdEXT(m_memoryObject, m_memorySize, GL_HANDLE_TYPE_OPAQUE_FD_EXT, m_fd);
+
+
+ int dupfd = fcntl(m_fd, F_DUPFD_CLOEXEC, 0);
+ if (dupfd < 0) {
+ perror("VulkanServerBuffer::toOpenGlTexture() Could not dup fd:");
+ return nullptr;
+ }
+
+ funcs->glImportMemoryFdEXT(m_memoryObject, m_memorySize, GL_HANDLE_TYPE_OPAQUE_FD_EXT, dupfd);
if (extraDebug) qDebug() << "glImportMemoryFdEXT" << hex << glGetError();