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.6 Change-Id: Ia32f20bfe8daea2e2346f3d446c978ae305d2f68 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 11333a097290e4247b27adbfd024d5aa964bed35) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
e7a9c8a559
commit
7f6b62f3fc
@ -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`...
|
||||
|
Loading…
x
Reference in New Issue
Block a user