mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-09 11:27:28 -03:00
Merge bitcoin/bitcoin#31521: fuzz: Fix misplaced SeedRand::ZEROS
Some checks are pending
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
Some checks are pending
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
fadd568931
fuzz: Fix misplaced SeedRand::ZEROS (MarcoFalke) Pull request description: After commitfae63bf130
this must be placed even before test_setup. This is nice, because it makes the usage consistently appear in the first line. The change is moving a `SeedRandomForTest(SeedRand::ZEROS)` to happen earlier. This is fine, because it will either have no effect, or make the code more deterministic, because after commitfae63bf
, no other re-seeding other than `ZEROS` can happen in fuzz tests. ACKs for top commit: marcofleon: Re ACKfadd568931
brunoerg: code review ACKfadd568931
hodlinator: ACKfadd568931
Tree-SHA512: 54eadf19a1e850157a280fb252ece8797f37a9a50d3b0a01aa2c267bacbe8ef4ddea6cf3faadcbaa4ab9f53148edf08e3cee5dfb3eae928db582adf8373a5206
This commit is contained in:
commit
bb57017b29
2 changed files with 4 additions and 4 deletions
|
@ -24,12 +24,12 @@ struct CheckGlobalsImpl {
|
||||||
"The current fuzz target used the global random state.\n\n"
|
"The current fuzz target used the global random state.\n\n"
|
||||||
|
|
||||||
"This is acceptable, but requires the fuzz target to call \n"
|
"This is acceptable, but requires the fuzz target to call \n"
|
||||||
"SeedRandomStateForTest(SeedRand::ZEROS) at the beginning \n"
|
"SeedRandomStateForTest(SeedRand::ZEROS) in the first line \n"
|
||||||
"of processing the fuzz input.\n\n"
|
"of the FUZZ_TARGET function.\n\n"
|
||||||
|
|
||||||
"An alternative solution would be to avoid any use of globals.\n\n"
|
"An alternative solution would be to avoid any use of globals.\n\n"
|
||||||
|
|
||||||
"Without a solution, fuzz stability and determinism can lead \n"
|
"Without a solution, fuzz instability and non-determinism can lead \n"
|
||||||
"to non-reproducible bugs or inefficient fuzzing.\n\n"
|
"to non-reproducible bugs or inefficient fuzzing.\n\n"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::abort(); // Abort, because AFL may try to recover from a std::exit
|
std::abort(); // Abort, because AFL may try to recover from a std::exit
|
||||||
|
|
|
@ -21,6 +21,7 @@ using node::BlockAssembler;
|
||||||
|
|
||||||
FUZZ_TARGET(utxo_total_supply)
|
FUZZ_TARGET(utxo_total_supply)
|
||||||
{
|
{
|
||||||
|
SeedRandomStateForTest(SeedRand::ZEROS);
|
||||||
/** The testing setup that creates a chainman only (no chainstate) */
|
/** The testing setup that creates a chainman only (no chainstate) */
|
||||||
ChainTestingSetup test_setup{
|
ChainTestingSetup test_setup{
|
||||||
ChainType::REGTEST,
|
ChainType::REGTEST,
|
||||||
|
@ -28,7 +29,6 @@ FUZZ_TARGET(utxo_total_supply)
|
||||||
.extra_args = {"-testactivationheight=bip34@2"},
|
.extra_args = {"-testactivationheight=bip34@2"},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
SeedRandomStateForTest(SeedRand::ZEROS); // Can not be done before test_setup
|
|
||||||
// Create chainstate
|
// Create chainstate
|
||||||
test_setup.LoadVerifyActivateChainstate();
|
test_setup.LoadVerifyActivateChainstate();
|
||||||
auto& node{test_setup.m_node};
|
auto& node{test_setup.m_node};
|
||||||
|
|
Loading…
Reference in a new issue