From d210cdc4355bb48786b474e41a8ed7f1a152626f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 3 Feb 2014 22:36:07 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20assertion=20failure=20in=20=E2=80=98nix-s?= =?UTF-8?q?tore=20--load-db=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Namely: nix-store: derivations.cc:242: nix::Hash nix::hashDerivationModulo(nix::StoreAPI&, nix::Derivation): Assertion `store.isValidPath(i->first)' failed. This happened because of the derivation output correctness check being applied before the references of a derivation are valid. --- src/libstore/local-store.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 4ac7d7f4e..4c8653883 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -1274,7 +1274,7 @@ void LocalStore::registerValidPaths(const ValidPathInfos & infos) if (isValidPath_(i->path)) updatePathInfo(*i); else - addValidPath(*i); + addValidPath(*i, false); paths.insert(i->path); } @@ -1284,6 +1284,17 @@ void LocalStore::registerValidPaths(const ValidPathInfos & infos) addReference(referrer, queryValidPathId(*j)); } + /* Check that the derivation outputs are correct. We can't do + this in addValidPath() above, because the references might + not be valid yet. */ + foreach (ValidPathInfos::const_iterator, i, infos) + if (isDerivation(i->path)) { + // FIXME: inefficient; we already loaded the + // derivation in addValidPath(). + Derivation drv = parseDerivation(readFile(i->path)); + checkDerivationOutputs(i->path, drv); + } + /* Do a topological sort of the paths. This will throw an error if a cycle is detected and roll back the transaction. Cycles can only occur when a derivation