QWaylandWindow: fix data race on mFrameCallbackTimedOut

WARNING: ThreadSanitizer: data race
  Write of size 1 at 0x7b5000008aa0 by thread T51 (mutexes: write M1, write M2):
    #0 QtWaylandClient::QWaylandWindow::waitForFrameSync(int) qtwayland/src/client/qwaylandwindow.cpp:784 (libQt6WaylandClient.so.6+0xdd6a9)
    #1 QtWaylandClient::QWaylandGLContext::swapBuffers(QPlatformSurface*) qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp:393 (libQt6WaylandEglClientHwIntegration.so.6+0xc706)
    #2 QOpenGLContext::swapBuffers(QSurface*) qtbase/src/gui/kernel/qopenglcontext.cpp:783 (libQt6Gui.so.6+0x80c6df)
    #3 QRhiGles2::endFrame(QRhiSwapChain*, QFlags<QRhi::EndFrameFlag>) qtbase/src/gui/rhi/qrhigles2.cpp:1984 (libQt6Gui.so.6+0x85bbda)
    #4 QRhi::endFrame(QRhiSwapChain*, QFlags<QRhi::EndFrameFlag>) qtbase/src/gui/rhi/qrhi.cpp:7689 (libQt6Gui.so.6+0x58faf0)
    #5 QSGRenderThread::syncAndRender() qtdeclarative/src/quick/scenegraph/qsgthreadedrenderloop.cpp:748 (libQt6Quick.so.6+0x7bb88a)

  Previous write of size 1 at 0x7b5000008aa0 by main thread:
    #0 QtWaylandClient::QWaylandWindow::timerEvent(QTimerEvent*) qtwayland/src/client/qwaylandwindow.cpp:1480 (libQt6WaylandClient.so.6+0xdc079)

Pick-to: 6.9 6.8 6.5
Change-Id: Ieb8819c5a273e6581975b258d4728bb6f3325da6
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
This commit is contained in:
David Faure 2025-04-11 14:17:33 +02:00
parent 3dc73f701b
commit 71dedf56d7

View File

@ -301,7 +301,7 @@ protected:
GestureState mGestureState = GestureNotActive;
#endif
bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
std::atomic_bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
int mFrameCallbackCheckIntervalTimerId = -1;
QAtomicInt mWaitingForUpdateDelivery = false;