From b0c016ae7d1b04f5bd89ccd54b3698bb3d76d38b Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 24 Nov 2025 15:03:46 -0500 Subject: [PATCH] `DummyStore` build trace holds `UnkeyedRealisation` by value Otherwise the equality instance we need to add will be messed up. --- src/libstore-tests/dummy-store.cc | 2 +- src/libstore/dummy-store.cc | 7 +++---- src/libstore/include/nix/store/dummy-store-impl.hh | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/libstore-tests/dummy-store.cc b/src/libstore-tests/dummy-store.cc index 3dd8137a3..c87b8d773 100644 --- a/src/libstore-tests/dummy-store.cc +++ b/src/libstore-tests/dummy-store.cc @@ -27,7 +27,7 @@ TEST(DummyStore, realisation_read) .outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv"}, }; - store->buildTrace.insert({drvHash, {{outputName, make_ref(value)}}}); + store->buildTrace.insert({drvHash, {{outputName, value}}}); auto value2 = store->queryRealisation({drvHash, outputName}); diff --git a/src/libstore/dummy-store.cc b/src/libstore/dummy-store.cc index c45a13cc3..57bbcd231 100644 --- a/src/libstore/dummy-store.cc +++ b/src/libstore/dummy-store.cc @@ -320,9 +320,8 @@ struct DummyStoreImpl : DummyStore void registerDrvOutput(const Realisation & output) override { - auto ref = make_ref(output); - buildTrace.insert_or_visit({output.id.drvHash, {{output.id.outputName, ref}}}, [&](auto & kv) { - kv.second.insert_or_assign(output.id.outputName, make_ref(output)); + buildTrace.insert_or_visit({output.id.drvHash, {{output.id.outputName, output}}}, [&](auto & kv) { + kv.second.insert_or_assign(output.id.outputName, output); }); } @@ -333,7 +332,7 @@ struct DummyStoreImpl : DummyStore buildTrace.cvisit(drvOutput.drvHash, [&](const auto & kv) { if (auto it = kv.second.find(drvOutput.outputName); it != kv.second.end()) { visited = true; - callback(it->second.get_ptr()); + callback(std::make_shared(it->second)); } }); diff --git a/src/libstore/include/nix/store/dummy-store-impl.hh b/src/libstore/include/nix/store/dummy-store-impl.hh index 137f81c9b..095767aaf 100644 --- a/src/libstore/include/nix/store/dummy-store-impl.hh +++ b/src/libstore/include/nix/store/dummy-store-impl.hh @@ -47,7 +47,7 @@ struct DummyStore : virtual Store * outer map for the derivation, and inner maps for the outputs of a * given derivation. */ - boost::concurrent_flat_map>> buildTrace; + boost::concurrent_flat_map> buildTrace; DummyStore(ref config) : Store{*config}