summaryrefslogtreecommitdiffstats
path: root/src/concurrent/qtconcurrentthreadengine.cpp
diff options
context:
space:
mode:
authorSona Kurazyan <[email protected]>2020-04-02 10:33:49 +0200
committerSona Kurazyan <[email protected]>2020-04-03 19:46:04 +0200
commit1812830ac3d5b167ddbb998cef58096d47da9989 (patch)
tree94faced57c9af4f74305b5f43b7fdfdfe5acab0f /src/concurrent/qtconcurrentthreadengine.cpp
parent6a6482cb8d2e71296e4c6ae35190a551fc4c6530 (diff)
Fix potential race condition in QtConcurrent blocking methods
QtConcurrent::blocking*() methods are using the ExceptionStore directly, which is not thread safe. In case if there's an exception thrown from multiple threads there may be a race condition. Added a lock to avoid that. Change-Id: I5de9928f91f5f43951b9bf9c4594694dc0ca0328 Reviewed-by: Vitaly Fanaskov <[email protected]> Reviewed-by: MÃ¥rten Nordheim <[email protected]>
Diffstat (limited to 'src/concurrent/qtconcurrentthreadengine.cpp')
-rw-r--r--src/concurrent/qtconcurrentthreadengine.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/concurrent/qtconcurrentthreadengine.cpp b/src/concurrent/qtconcurrentthreadengine.cpp
index 3293c49507d..cf424912b37 100644
--- a/src/concurrent/qtconcurrentthreadengine.cpp
+++ b/src/concurrent/qtconcurrentthreadengine.cpp
@@ -322,10 +322,13 @@ void ThreadEngineBase::run() // implements QRunnable.
void ThreadEngineBase::handleException(const QException &exception)
{
- if (futureInterface)
+ if (futureInterface) {
futureInterface->reportException(exception);
- else if (!exceptionStore.hasException())
- exceptionStore.setException(exception);
+ } else {
+ QMutexLocker lock(&mutex);
+ if (!exceptionStore.hasException())
+ exceptionStore.setException(exception);
+ }
}
#endif