summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qprocess_unix.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>2013-04-19 18:11:05 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-20 15:20:26 +0200
commit85e61297f7b02297641826332dbdbc845a88c34b (patch)
treedb3d836309af897f70672adbfc4a118ff70321ff /src/corelib/io/qprocess_unix.cpp
parentc30a7ecce1a236514599825cc818323d8affd9dc (diff)
restore QProcessEnvironment shared data thread safety on unix
implicit sharing together with 'mutable' is a time bomb. we need to protect the nameMap, because concurrent "reads" may try to insert into the hash, which would go boom. we need to protect the key/value of Hash objects, because while the refcounting is atomic, the d pointer assignments are not, which would also go boom. we can simply use a QMutex to protect the whole environment, because it is very cheap in the uncontended case. Task-number: QTBUG-30779 Change-Id: Iaad5720041ca06691d75eb9c6c0e1c120d4a7b46 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/io/qprocess_unix.cpp')
-rw-r--r--src/corelib/io/qprocess_unix.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 79a75b0321..e9957d2384 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -617,8 +617,10 @@ void QProcessPrivate::startProcess()
// Duplicate the environment.
int envc = 0;
char **envp = 0;
- if (environment.d.constData())
+ if (environment.d.constData()) {
+ QProcessEnvironmentPrivate::MutexLocker locker(environment.d);
envp = _q_dupEnvironment(environment.d.constData()->hash, &envc);
+ }
// Encode the working directory if it's non-empty, otherwise just pass 0.
const char *workingDirPtr = 0;