From cad39f86fb5a81f0e3b5116e8e989bab8af89718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc?= Date: Sat, 19 Apr 2025 20:09:11 +0200 Subject: [PATCH] bench: ensure wallet migration benchmark runs exactly once MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The migration benchmark crashes if run more than once, because of `std::move(wallet)` and leaves subsequent iterations in an undefined state - avoiding `UndefinedBehaviorSanitizer` null‑dereference error. --- src/bench/wallet_migration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bench/wallet_migration.cpp b/src/bench/wallet_migration.cpp index 87710d41d80..afb79d98afb 100644 --- a/src/bench/wallet_migration.cpp +++ b/src/bench/wallet_migration.cpp @@ -61,7 +61,7 @@ static void WalletMigration(benchmark::Bench& bench) batch.WriteKey(pubkey, key.GetPrivKey(), CKeyMetadata()); } - bench.epochs(/*numEpochs=*/1) + bench.epochs(/*numEpochs=*/1).epochIterations(/*numIters=*/1) // run the migration exactly once .run([&] { auto res{MigrateLegacyToDescriptor(std::move(wallet), /*passphrase=*/"", *loader->context(), /*was_loaded=*/false)}; assert(res);