diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2018-02-12 16:56:12 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2018-02-12 17:06:06 +0100 |
commit | 4f09ce7940689887a18d4aa44367d2e6abeaa3cf (patch) | |
tree | 25f9fe61ac75c54cc60d8348b40593c9aa0112b5 /src/libstore/local-store.cc | |
parent | 35fd31770c589f28c569e7868f868a5b558cf83d (diff) |
Fix 'deadlock: trying to re-acquire self-held lock'
This was caused by derivations with 'allowSubstitutes = false'. Such
derivations will be built locally. However, if there is another
SubstitionGoal that has the output of the first derivation in its
closure, then the path will be simultaneously built and substituted.
There was a check to catch this situation (via pathIsLockedByMe()),
but it no longer worked reliably because substitutions are now done in
another thread. (Thus the comment 'It can't happen between here and
the lockPaths() call below because we're not allowing multi-threading'
was no longer valid.)
The fix is to handle the path already being locked in both
SubstitutionGoal and DerivationGoal.
Diffstat (limited to 'src/libstore/local-store.cc')
-rw-r--r-- | src/libstore/local-store.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 7afecc1cf..8a79fc723 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -992,8 +992,8 @@ void LocalStore::addToStore(const ValidPathInfo & info, const ref<std::string> & /* Lock the output path. But don't lock if we're being called from a build hook (whose parent process already acquired a lock on this path). */ - Strings locksHeld = tokenizeString<Strings>(getEnv("NIX_HELD_LOCKS")); - if (find(locksHeld.begin(), locksHeld.end(), info.path) == locksHeld.end()) + static auto locksHeld = tokenizeString<PathSet>(getEnv("NIX_HELD_LOCKS")); + if (!locksHeld.count(info.path)) outputLock.lockPaths({realPath}); if (repair || !isValidPath(info.path)) { |