diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2018-02-07 15:57:15 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2018-02-16 09:36:08 +0000 |
commit | 33006868d9d1bf1bee214f6d55c2cafde3cd2e3a (patch) | |
tree | 3658b5dfa5be9b70a5becbef5c899860145cf050 /src/lib/corelib/buildgraph/productbuilddata.h | |
parent | 24471740f276fc7fb3b662bd18ae637127368a9f (diff) |
Fix race condition when accessing the artifacts map from JavaScript
JavaScript commands, which potentially read the artifacts map, can run
concurrently to another rule's outputArtifacts script, which writes the
data structure backing said artifacts map. Therefore, we need to
synchronize the accesses to that data structure.
Note: While this fixes the undefined behavior on the language level
(i.e. no crashes), rule authors still need to ensure the artifacts they
are interested in are present already, e.g. by using suitable input
tags.
Change-Id: Id50d0b926975be7b734366cae4cad9cac6ec36a6
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/lib/corelib/buildgraph/productbuilddata.h')
-rw-r--r-- | src/lib/corelib/buildgraph/productbuilddata.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lib/corelib/buildgraph/productbuilddata.h b/src/lib/corelib/buildgraph/productbuilddata.h index 8fe998f09..fd24c3ba5 100644 --- a/src/lib/corelib/buildgraph/productbuilddata.h +++ b/src/lib/corelib/buildgraph/productbuilddata.h @@ -47,6 +47,8 @@ #include <QtCore/qlist.h> +#include <mutex> + namespace qbs { namespace Internal { @@ -75,7 +77,7 @@ public: void removeAllArtifactsWithChangedInputsForRule(const RuleConstPtr &rule); bool ruleHasArtifactWithChangedInputs(const RuleConstPtr &rule) const; - ArtifactSetByFileTag artifactsByFileTag() const { return m_artifactsByFileTag; } + ArtifactSetByFileTag artifactsByFileTag() const; AllRescuableArtifactData rescuableArtifactData() const { return m_rescuableArtifactData; } void setRescuableArtifactData(const AllRescuableArtifactData &rad); @@ -107,6 +109,7 @@ private: unsigned int m_buildPriority; ArtifactSetByFileTag m_artifactsByFileTag; + mutable std::mutex m_artifactsMapMutex; typedef QHash<RuleConstPtr, ArtifactSet> ArtifactSetByRule; ArtifactSetByRule m_artifactsWithChangedInputsPerRule; |