Bitcoin Core 28.99.0
P2P Digital Currency
check_globals.cpp
Go to the documentation of this file.
1// Copyright (c) 2024-present The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
6
7#include <test/util/random.h>
8
9#include <iostream>
10#include <memory>
11#include <optional>
12#include <string>
13
16 {
17 g_used_g_prng = false;
19 }
21 {
23 std::cerr << "\n\n"
24 "The current fuzz target used the global random state.\n\n"
25
26 "This is acceptable, but requires the fuzz target to call \n"
27 "SeedRandomStateForTest(SeedRand::ZEROS) at the beginning \n"
28 "of processing the fuzz input.\n\n"
29
30 "An alternative solution would be to avoid any use of globals.\n\n"
31
32 "Without a solution, fuzz stability and determinism can lead \n"
33 "to non-reproducible bugs or inefficient fuzzing.\n\n"
34 << std::endl;
35 std::abort(); // Abort, because AFL may try to recover from a std::exit
36 }
37 }
38};
39
40CheckGlobals::CheckGlobals() : m_impl(std::make_unique<CheckGlobalsImpl>()) {}
std::atomic< bool > g_used_g_prng
Definition: random.cpp:674
std::atomic< bool > g_seeded_g_prng_zero
Definition: random.cpp:15