summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2023-12-21 11:46:00 +0100
committerIvan Solovev <ivan.solovev@qt.io>2024-01-09 00:55:41 +0000
commit11333a097290e4247b27adbfd024d5aa964bed35 (patch)
tree9d13ba56fce37031b13df9cc80a1615033451c83
parent84588c072159d89ca937a3024c5ee5d76ff8de82 (diff)
QFuture: immediately delete watcher after the context is destroyed
We used deleteLater(), which was triggering ASAN use-after-free error. Apparently, what could happen is that after the context was destroyed, we called deleteLater(), but if at this point the previous future got finished, we still tried to emit watcher->run() to execute the continuation. And then the watcher got deleted. This patch replaces deleteLater() with a plain delete call. This looks safe, because the watcher is only accessed while holding the lock. Amends 59e21a536f7f81625216dc7a621e7be59919da33. Fixes: QTBUG-120302 Pick-to: 6.7 6.6 Change-Id: Ia32f20bfe8daea2e2346f3d446c978ae305d2f68 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
-rw-r--r--src/corelib/thread/qfutureinterface.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/thread/qfutureinterface.cpp b/src/corelib/thread/qfutureinterface.cpp
index 0292d5b6ca..d3d44a169d 100644
--- a/src/corelib/thread/qfutureinterface.cpp
+++ b/src/corelib/thread/qfutureinterface.cpp
@@ -76,7 +76,7 @@ void QtPrivate::watchContinuationImpl(const QObject *context, QSlotObjectBase *s
auto watcherMutex = std::make_shared<QRecursiveMutex>();
const auto destroyWatcher = [watcherMutex, watcher]() mutable {
QMutexLocker lock(watcherMutex.get());
- watcher->deleteLater();
+ delete watcher;
};
// ### we're missing a convenient way to `QObject::connect()` to a `QSlotObjectBase`...