From 01ef243b5478f249adf0532aa6639de462e9957d Mon Sep 17 00:00:00 2001 From: Thomas Senyk Date: Thu, 30 Nov 2023 15:09:34 +0100 Subject: client texture cleanup: fix crash in clean-up lambda The dtor of WaylandEgl[Stream]ClientBuffer used to only clean-up the aboutToBeDestroyed-connection/lambda if it's integration is still present. This was a pointless condition as that clean-up is not depending on the integration and can lead to access of dead memory (when the Buffer is already deleted but the lambda is then later called due to QOpenGLContext::aboutToBeDestroyed) Fixed by moving the clean-up into it's own scope (needs a scope due to QMutexLocker) Pick-to: 6.6 6.5 Change-Id: Ib3b6e54365f66484f249ee449cb3b27029f5ce7c Reviewed-by: Eskil Abrahamsen Blomfeldt (cherry picked from commit acce7bc40d287eff826cd97dbea595da3050669f) Reviewed-by: Qt Cherry-pick Bot --- .../compositor/wayland-egl/waylandeglclientbufferintegration.cpp | 2 ++ .../wayland-eglstream-controller/waylandeglstreamintegration.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp index 38b0e0c4b..c8819ba1f 100644 --- a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp +++ b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp @@ -525,7 +525,9 @@ WaylandEglClientBuffer::~WaylandEglClientBuffer() if (d->egl_stream) p->funcs->destroy_stream(p->egl_display, d->egl_stream); + } + { QMutexLocker locker(&d->texturesLock); for (int i=0; i<3; i++) { diff --git a/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.cpp b/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.cpp index 02d289ce0..0924f0fd7 100644 --- a/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.cpp +++ b/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.cpp @@ -399,7 +399,9 @@ WaylandEglStreamClientBuffer::~WaylandEglStreamClientBuffer() if (p) { if (d->egl_stream) p->funcs->destroy_stream(p->egl_display, d->egl_stream); + } + { QMutexLocker locker(&d->texturesLock); for (int i=0; i<3; i++) { -- cgit v1.2.3