about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-02-03T21·36+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-02-03T21·36+0100
commitd210cdc4355bb48786b474e41a8ed7f1a152626f (patch)
tree6de4a9e9a8b0c3c8c88bbe71e20241b372fad165 /src
parent73a775f3b757d105a9987c5e469d6a3e8f32024f (diff)
Fix assertion failure in ‘nix-store --load-db’
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.
Diffstat (limited to 'src')
-rw-r--r--src/libstore/local-store.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 4ac7d7f4e6f7..4c86538837a8 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