From 4781e2a088b5bdbe705397994059153fa88b41d5 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 6 Nov 2024 17:07:30 +0100 Subject: [PATCH] MockCompositor: Protect against race condition The QList m_fractionalScales was being changed from both the main thread and the dispatch thread. This lead to read-after-free AddressSanitizer errors when running autotests. Using a DirectConnection makes sure that both appending and removal happens in the same thread. This does not fix a theoretical race condition in DefaultCompositor::fractionalScale(). Fixes: QTBUG-130627 Pick-to: 6.8 Change-Id: Ie73f80d08929bcfcbd9940acdb4f86233df013cb Reviewed-by: David Edmundson --- tests/auto/wayland/shared/fractionalscalev1.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/wayland/shared/fractionalscalev1.cpp b/tests/auto/wayland/shared/fractionalscalev1.cpp index 28c77802523..e2ad29897cc 100644 --- a/tests/auto/wayland/shared/fractionalscalev1.cpp +++ b/tests/auto/wayland/shared/fractionalscalev1.cpp @@ -16,7 +16,7 @@ void FractionalScaleManager::wp_fractional_scale_manager_v1_get_fractional_scale auto *scaler = new FractionalScale(s, resource->client(), id, resource->version()); connect(scaler, &QObject::destroyed, this, [this, scaler]() { m_fractionalScales.removeOne(scaler); - }); + }, Qt::DirectConnection); m_fractionalScales << scaler; }