Skip to content

Commit b4e0817

Browse files
fanquakeClaude Code
authored andcommitted
Merge 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
1 parent e7f515c commit b4e0817

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/test/fuzz/transaction.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,17 @@ FUZZ_TARGET(transaction, .init = initialize_transaction)
9393
const CCoinsViewCache coins_view_cache(&coins_view);
9494
(void)AreInputsStandard(tx, coins_view_cache);
9595

96-
UniValue u(UniValue::VOBJ);
97-
TxToUniv(tx, /*block_hash=*/uint256::ZERO, /*entry=*/u);
98-
TxToUniv(tx, /*block_hash=*/uint256::ONE, /*entry=*/u);
96+
if (tx.GetTotalSize() < 250'000) { // Avoid high memory usage (with msan) due to json encoding
97+
{
98+
UniValue u{UniValue::VOBJ};
99+
TxToUniv(tx, /*block_hash=*/uint256::ZERO, /*entry=*/u);
100+
}
101+
{
102+
UniValue u{UniValue::VOBJ};
103+
TxToUniv(tx, /*block_hash=*/uint256::ONE, /*entry=*/u);
104+
}
105+
}
99106

100107
// TxToUniv(tx, /*block_hash=*/uint256::ZERO, /*include_addresses=*/true, u);
101-
// TxToUniv(tx, /*block_hash=*/uint256::ONE, /*include_addresses=*/false, u);
108+
// TxToUniv(tx, /*block_hash=*/uint256::ONE, /*include_addresses=*/false, u)
102109
}

0 commit comments

Comments
 (0)