From f3c88f297d837f73d8123cb12564d237d7d0df87 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Wed, 21 Dec 2011 17:14:28 +0000 Subject: [PATCH] Detect and reject mutually-referential outputs There is probably a more efficient way to do this. --- src/libstore/build.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libstore/build.cc b/src/libstore/build.cc index a8ef9b23e..2ebcbf5a8 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -1986,6 +1986,15 @@ void DerivationGoal::computeClosure() info.deriver = drvPath; infos.push_back(info); } + + /* Mutually recursive outputs are not allowed */ + foreach (ValidPathInfos::iterator, i, infos) + foreach (ValidPathInfos::iterator, j, infos) + if ((i->path != j->path) && + (i->references.find(j->path) != i->references.end()) && + (j->references.find(i->path) != j->references.end())) + throw BuildError(format("Mutually referential outputs are not allowed: outputs `%1%' and `%2%' refer to each other") % i->path % j->path); + worker.store.registerValidPaths(infos); /* It is now safe to delete the lock files, since all future