Skip to content

Commit d32d77f

Browse files
committed
Allocate ExprParseFile on the heap for now
#14013 (comment)
1 parent 5f60602 commit d32d77f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/libexpr/eval.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,9 +1035,10 @@ Value * ExprPath::maybeThunk(EvalState & state, Env & env)
10351035
* from a thunk, ensuring that every file is parsed/evaluated only
10361036
* once (via the thunk stored in `EvalState::fileEvalCache`).
10371037
*/
1038-
struct ExprParseFile : Expr
1038+
struct ExprParseFile : Expr, gc
10391039
{
1040-
SourcePath & path;
1040+
// FIXME: make this a reference (see below).
1041+
SourcePath path;
10411042
bool mustBeTrivial;
10421043

10431044
ExprParseFile(SourcePath & path, bool mustBeTrivial)
@@ -1088,14 +1089,18 @@ void EvalState::evalFile(const SourcePath & path, Value & v, bool mustBeTrivial)
10881089
}
10891090

10901091
Value * vExpr;
1091-
ExprParseFile expr{*resolvedPath, mustBeTrivial};
1092+
// FIXME: put ExprParseFile on the stack instead of the heap once
1093+
// https://github.com/NixOS/nix/pull/13930 is merged. That will ensure
1094+
// the post-condition that `expr` is unreachable after
1095+
// `forceValue()` returns.
1096+
auto expr = new ExprParseFile{*resolvedPath, mustBeTrivial};
10921097

10931098
fileEvalCache->try_emplace_and_cvisit(
10941099
*resolvedPath,
10951100
nullptr,
10961101
[&](auto & i) {
10971102
vExpr = allocValue();
1098-
vExpr->mkThunk(&baseEnv, &expr);
1103+
vExpr->mkThunk(&baseEnv, expr);
10991104
i.second = vExpr;
11001105
},
11011106
[&](auto & i) { vExpr = i.second; });

0 commit comments

Comments
 (0)