Skip to content

Commit cad39f8

Browse files
committed
bench: ensure wallet migration benchmark runs exactly once
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.
1 parent c1f458a commit cad39f8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/bench/wallet_migration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static void WalletMigration(benchmark::Bench& bench)
6161
batch.WriteKey(pubkey, key.GetPrivKey(), CKeyMetadata());
6262
}
6363

64-
bench.epochs(/*numEpochs=*/1)
64+
bench.epochs(/*numEpochs=*/1).epochIterations(/*numIters=*/1) // run the migration exactly once
6565
.run([&] {
6666
auto res{MigrateLegacyToDescriptor(std::move(wallet), /*passphrase=*/"", *loader->context(), /*was_loaded=*/false)};
6767
assert(res);

0 commit comments

Comments
 (0)