Skip to content

Commit f1b4975

Browse files
committed
Merge bitcoin/bitcoin#27921: fuzz: Avoid OOM in transaction fuzz target
fa31c4d fuzz: Avoid OOM in transaction fuzz target (MarcoFalke) Pull request description: To test: `FUZZ=transaction /usr/bin/time -f '%Us %MkB' ./src/test/fuzz/fuzz ../btc_qa_assets/fuzz_seed_corpus/transaction/9dc22b51df0af05ee5a595beefb0ce291feb6b99` Before: `0.72s 249636kB` After: `0.30s 92128kB` ACKs for top commit: dergoegge: utACK fa31c4d Tree-SHA512: 958fc54e7af31af7db3e3e1fb37553ae24de251c7fdeea3d68ec168f03db48de6aa54a96bf971f9cc804e94ff8a02fda9c56d7e85869d62962f6f020568e3a7b
2 parents d23cdf6 + fa31c4d commit f1b4975

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/test/fuzz/transaction.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,14 @@ FUZZ_TARGET_INIT(transaction, initialize_transaction)
101101
(void)AreInputsStandard(tx, coins_view_cache);
102102
(void)IsWitnessStandard(tx, coins_view_cache);
103103

104-
UniValue u(UniValue::VOBJ);
105-
TxToUniv(tx, /*block_hash=*/uint256::ZERO, /*entry=*/u);
106-
TxToUniv(tx, /*block_hash=*/uint256::ONE, /*entry=*/u);
104+
if (tx.GetTotalSize() < 250'000) { // Avoid high memory usage (with msan) due to json encoding
105+
{
106+
UniValue u{UniValue::VOBJ};
107+
TxToUniv(tx, /*block_hash=*/uint256::ZERO, /*entry=*/u);
108+
}
109+
{
110+
UniValue u{UniValue::VOBJ};
111+
TxToUniv(tx, /*block_hash=*/uint256::ONE, /*entry=*/u);
112+
}
113+
}
107114
}

0 commit comments

Comments
 (0)