about summary refs log tree commit diff
path: root/src/libexpr
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/attr-path.cc1
-rw-r--r--src/libexpr/common-opts.cc1
-rw-r--r--src/libexpr/eval.cc1
-rw-r--r--src/libexpr/eval.hh3
-rw-r--r--src/libexpr/expr-to-xml.hh1
-rw-r--r--src/libexpr/get-drvs.cc1
-rw-r--r--src/libexpr/parser.y8
-rw-r--r--src/libexpr/primops.cc1
8 files changed, 14 insertions, 3 deletions
diff --git a/src/libexpr/attr-path.cc b/src/libexpr/attr-path.cc
index e8e4c050cc84..092d9b1c28d0 100644
--- a/src/libexpr/attr-path.cc
+++ b/src/libexpr/attr-path.cc
@@ -1,6 +1,7 @@
 #include "attr-path.hh"
 #include "nixexpr-ast.hh"
 #include "util.hh"
+#include "aterm.hh"
 
 
 namespace nix {
diff --git a/src/libexpr/common-opts.cc b/src/libexpr/common-opts.cc
index 9e3f8f9614da..0ef488373614 100644
--- a/src/libexpr/common-opts.cc
+++ b/src/libexpr/common-opts.cc
@@ -2,6 +2,7 @@
 #include "../libmain/shared.hh"
 #include "util.hh"
 #include "parser.hh"
+#include "aterm.hh"
 
 
 namespace nix {
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index cd9c64594747..5a0e8bc27405 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -6,6 +6,7 @@
 #include "derivations.hh"
 #include "nixexpr-ast.hh"
 #include "globals.hh"
+#include "aterm.hh"
 
 
 #define LocalNoInline(f) static f __attribute__((noinline)); f
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh
index fed6d347266b..00d0e3564548 100644
--- a/src/libexpr/eval.hh
+++ b/src/libexpr/eval.hh
@@ -3,9 +3,10 @@
 
 #include <map>
 
-#include "aterm.hh"
 #include "nixexpr.hh"
 
+typedef union _ATermList * ATermList;
+
 
 namespace nix {
 
diff --git a/src/libexpr/expr-to-xml.hh b/src/libexpr/expr-to-xml.hh
index 36b8e40424d8..576a46fc36d0 100644
--- a/src/libexpr/expr-to-xml.hh
+++ b/src/libexpr/expr-to-xml.hh
@@ -5,7 +5,6 @@
 #include <map>
 
 #include "nixexpr.hh"
-#include "aterm.hh"
 
 namespace nix {
 
diff --git a/src/libexpr/get-drvs.cc b/src/libexpr/get-drvs.cc
index 1442d7988b8b..cd5a85e5b974 100644
--- a/src/libexpr/get-drvs.cc
+++ b/src/libexpr/get-drvs.cc
@@ -1,6 +1,7 @@
 #include "get-drvs.hh"
 #include "nixexpr-ast.hh"
 #include "util.hh"
+#include "aterm.hh"
 
 
 namespace nix {
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index c4afb72eacd5..8706ce025477 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -85,6 +85,10 @@ static Expr fixAttrs(bool recursive, ATermList as)
 {
     Tree attrs;
 
+    /* This ATermMap is needed to ensure that the `leaf' fields in the
+       Tree nodes are not garbage collected. */
+    ATermMap gcRoots;
+
     for (ATermIterator i(as); i; ++i) {
         ATermList names, attrPath; Expr src, e; ATerm name, pos;
 
@@ -95,7 +99,9 @@ static Expr fixAttrs(bool recursive, ATermList as)
                     throw ParseError(format("duplicate definition of attribute `%1%' at %2%")
                         % showAttrPath(ATmakeList1(*j)) % showPos(pos));
                 Tree & t(attrs.children[*j]);
-                t.leaf = fromScope ? makeVar(*j) : makeSelect(src, *j);
+                Expr leaf = fromScope ? makeVar(*j) : makeSelect(src, *j);
+                gcRoots.set(leaf, leaf);
+                t.leaf = leaf;
                 t.pos = pos;
                 if (recursive && fromScope) t.recursive = false;
             }
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 7dddc91a86ab..bf2752d0d95d 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -8,6 +8,7 @@
 #include "nixexpr-ast.hh"
 #include "parser.hh"
 #include "names.hh"
+#include "aterm.hh"
 
 #include <sys/types.h>
 #include <sys/stat.h>