From c1c5dd7449d54dbec48dccd26f3b3fb09e26b290 Mon Sep 17 00:00:00 2001 From: Pamplemousse Date: Wed, 21 Jul 2021 15:31:08 -0700 Subject: Avoid global counters Signed-off-by: Pamplemousse --- src/libexpr/eval.hh | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/libexpr/eval.hh') diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index e3eaed6d3..47db8b2ba 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -316,8 +316,10 @@ private: unsigned long nrValuesInEnvs = 0; unsigned long nrValues = 0; unsigned long nrListElems = 0; + unsigned long nrLookups = 0; unsigned long nrAttrsets = 0; unsigned long nrAttrsInAttrsets = 0; + unsigned long nrAvoided = 0; unsigned long nrOpUpdates = 0; unsigned long nrOpUpdateValuesCopied = 0; unsigned long nrListConcats = 0; @@ -339,6 +341,11 @@ private: friend struct ExprOpUpdate; friend struct ExprOpConcatLists; + friend struct ExprVar; + friend struct ExprString; + friend struct ExprInt; + friend struct ExprFloat; + friend struct ExprPath; friend struct ExprSelect; friend void prim_getAttr(EvalState & state, const Pos & pos, Value * * args, Value & v); friend void prim_match(EvalState & state, const Pos & pos, Value * * args, Value & v); -- cgit v1.2.3 From bef40c29491ba9b31c85b9b89a5342979344f583 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 29 Jun 2021 21:09:48 +0200 Subject: Add --eval-store option --- src/libexpr/eval.hh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/libexpr/eval.hh') diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index e3eaed6d3..a7aebb8ef 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -94,8 +94,12 @@ public: Value vEmptySet; + /* Store used to materialise .drv files. */ const ref store; + /* Store used to build stuff. */ + const ref buildStore; + private: SrcToStore srcToStore; @@ -128,7 +132,10 @@ private: public: - EvalState(const Strings & _searchPath, ref store); + EvalState( + const Strings & _searchPath, + ref store, + std::shared_ptr buildStore = nullptr); ~EvalState(); void addToSearchPath(const string & s); -- cgit v1.2.3 From 8f9429dcab9e806a61a8541cd3fd7c1c19c17ae8 Mon Sep 17 00:00:00 2001 From: Taeer Bar-Yam Date: Thu, 29 Jul 2021 12:03:07 -0400 Subject: add antiquotations to paths --- src/libexpr/eval.hh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/libexpr/eval.hh') diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 47db8b2ba..ad6fb7ff4 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -217,7 +217,8 @@ public: booleans and lists to a string. If `copyToStore' is set, referenced paths are copied to the Nix store as a side effect. */ string coerceToString(const Pos & pos, Value & v, PathSet & context, - bool coerceMore = false, bool copyToStore = true); + bool coerceMore = false, bool copyToStore = true, + bool canonizePath = true); string copyPathToStore(PathSet & context, const Path & path); -- cgit v1.2.3 From f10465774fafaa2423cb05e02b38e03ed2abded7 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 29 Aug 2021 18:09:13 +0200 Subject: Force all Pos* to be non-null This fixes a class of crashes and introduces ptr to make the code robust against this failure mode going forward. Thanks regnat for the idea of a ref without overhead! Closes #4895 Closes #4893 Closes #5127 Closes #5113 --- src/libexpr/eval.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libexpr/eval.hh') diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 6f3474854..f3684db79 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -308,7 +308,7 @@ public: void mkList(Value & v, size_t length); void mkAttrs(Value & v, size_t capacity); void mkThunk_(Value & v, Expr * expr); - void mkPos(Value & v, Pos * pos); + void mkPos(Value & v, ptr pos); void concatLists(Value & v, size_t nrLists, Value * * lists, const Pos & pos); -- cgit v1.2.3 From 8bc76acc7c3665897a1b7e14574b379664f058d2 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 29 Aug 2021 18:55:38 +0200 Subject: Move vCallFlake into EvalState This fixes a use-after-free bug: 1. s = new EvalState(); 2. callFlake() 3. static vCallFlake now references s 4. delete s; 5. s2 = new EvalState(); 6. callFlake() 7. static vCallFlake still references s 8. crash Nix 2.3 did not have a problem with recreating EvalState. --- src/libexpr/eval.hh | 1 + 1 file changed, 1 insertion(+) (limited to 'src/libexpr/eval.hh') diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 6f3474854..22b0a584b 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -100,6 +100,7 @@ public: /* Store used to build stuff. */ const ref buildStore; + RootValue vCallFlake = nullptr; private: SrcToStore srcToStore; -- cgit v1.2.3 From 8656b130ea6defe6a7ef04b564ff391caa64a450 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 29 Aug 2021 19:31:52 +0200 Subject: Fix use after free with vImportedDrvToDerivation --- src/libexpr/eval.hh | 1 + 1 file changed, 1 insertion(+) (limited to 'src/libexpr/eval.hh') diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 22b0a584b..03dcfcf21 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -101,6 +101,7 @@ public: const ref buildStore; RootValue vCallFlake = nullptr; + RootValue vImportedDrvToDerivation = nullptr; private: SrcToStore srcToStore; -- cgit v1.2.3 From 9da8f5e25d835e3bd1cc4280f2b69cfa4ab8d774 Mon Sep 17 00:00:00 2001 From: Taeer Bar-Yam Date: Tue, 31 Aug 2021 08:02:04 -0400 Subject: path antiquotations: canonizePath -> canonicalizePath --- src/libexpr/eval.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libexpr/eval.hh') diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index ad6fb7ff4..af000072a 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -218,7 +218,7 @@ public: referenced paths are copied to the Nix store as a side effect. */ string coerceToString(const Pos & pos, Value & v, PathSet & context, bool coerceMore = false, bool copyToStore = true, - bool canonizePath = true); + bool canonicalizePath = true); string copyPathToStore(PathSet & context, const Path & path); -- cgit v1.2.3 From 49a932fb18add471feefc469fb45fc44313bd5c6 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 13 Sep 2021 14:41:28 +0200 Subject: nix --help: Display help using lowdown instead of man Fixes #4476. Fixes #5231. --- src/libexpr/eval.hh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/libexpr/eval.hh') diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 93e1ef05f..b29feb134 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -172,6 +172,14 @@ public: trivial (i.e. doesn't require arbitrary computation). */ void evalFile(const Path & path, Value & v, bool mustBeTrivial = false); + /* Like `cacheFile`, but with an already parsed expression. */ + void cacheFile( + const Path & path, + const Path & resolvedPath, + Expr * e, + Value & v, + bool mustBeTrivial = false); + void resetFileCache(); /* Look up a file in the search path. */ -- cgit v1.2.3