about summary refs log tree commit diff
path: root/third_party/nix/src/nix/command.hh
diff options
context:
space:
mode:
authorAndreas Rammhold <andreas@rammhold.de>2020-04-13T19·09+0200
committertazjin <mail@tazj.in>2020-07-17T20·04+0000
commit5218c83b9ff24e15941382e1d065f87d562ba3ac (patch)
tree35a0ec36be7399a8e083887c879a7707ca102053 /third_party/nix/src/nix/command.hh
parent6c98d3d81ffd425882c8ccf74aa5a55494d6c461 (diff)
fix(3p/nix): allocate the vSourceExpr via uncollectable memory r/1352
Previously the memory would occasionally be collected during eval since
the GC doesn't consider the member variable as alive / doesn't scan the
region of memory where the pointer lives.

By using the traceable_allocator<T> allocator provided by Boehm GC we
can ensure the memory isn't collected. It should be properly freed when
SourceExprCommand goes out of scope.

Backported from:
https://github.com/NixOS/nix/commit/d2c371927e45c1d4e4f7e4ad331a3f68d67d5469

Change-Id: I1f7c745dbc66c7164bee50f4d9b0d437dbc7dd51
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1251
Tested-by: BuildkiteCI
Reviewed-by: isomer <isomer@tvl.fyi>
Diffstat (limited to 'third_party/nix/src/nix/command.hh')
-rw-r--r--third_party/nix/src/nix/command.hh4
1 files changed, 2 insertions, 2 deletions
diff --git a/third_party/nix/src/nix/command.hh b/third_party/nix/src/nix/command.hh
index 813fdb557d82..f7eaeb721620 100644
--- a/third_party/nix/src/nix/command.hh
+++ b/third_party/nix/src/nix/command.hh
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <memory>
 #include "libexpr/common-eval-args.hh"
 #include "libutil/args.hh"
 
@@ -80,8 +81,7 @@ struct SourceExprCommand : virtual Args, StoreCommand, MixEvalArgs {
 
  private:
   std::shared_ptr<EvalState> evalState;
-
-  Value* vSourceExpr = 0;
+  std::shared_ptr<Value> vSourceExpr;
 };
 
 enum RealiseMode { Build, NoBuild, DryRun };