aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-05-04 17:21:34 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-05-04 17:21:43 +0200
commit3f8f238deb5a72db04d29c899cea11df14cd984c (patch)
tree71c84837a7c0ae6f19c9080a189be8b0b27ae560 /src
parenta1c6434e19bc897311d25232ebbbf4f6585e4a2c (diff)
parentcf83b82cf04a57223ebed74b8935e56f74ed721b (diff)
downloadbitcoin-3f8f238deb5a72db04d29c899cea11df14cd984c.tar.xz
Merge bitcoin/bitcoin#21849: fuzz: Limit toxic test globals to their respective scope
cf83b82cf04a57223ebed74b8935e56f74ed721b fuzz: Limit toxic test globals to their respective scope (MarcoFalke) Pull request description: Globals in one fuzz target are toxic to all other fuzz targets, because we link all fuzz targets into one binary. Any code called by constructing the global will affect all other targets. This leads to incorrect coverage stats, false-positive crashes, ... ACKs for top commit: practicalswift: cr ACK cf83b82cf04a57223ebed74b8935e56f74ed721b: non-toxic is better than toxic! laanwj: Code review ACK cf83b82cf04a57223ebed74b8935e56f74ed721b Tree-SHA512: 5b3a37bcb36fce4160c94f877b2c07704527e3e1842092375c793d2eca77b996ae62889326094020855666bb34fa019fcfe92e8ff8430ce0372227f03ab2b907
Diffstat (limited to 'src')
-rw-r--r--src/test/fuzz/script_assets_test_minimizer.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/test/fuzz/script_assets_test_minimizer.cpp b/src/test/fuzz/script_assets_test_minimizer.cpp
index cec5212f42..a80338b965 100644
--- a/src/test/fuzz/script_assets_test_minimizer.cpp
+++ b/src/test/fuzz/script_assets_test_minimizer.cpp
@@ -133,8 +133,7 @@ unsigned int ParseScriptFlags(const std::string& str)
std::vector<std::string> words;
boost::algorithm::split(words, str, boost::algorithm::is_any_of(","));
- for (const std::string& word : words)
- {
+ for (const std::string& word : words) {
auto it = FLAG_NAMES.find(word);
if (it == FLAG_NAMES.end()) throw std::runtime_error("Unknown verification flag " + word);
flags |= it->second;
@@ -186,15 +185,19 @@ void Test(const std::string& str)
}
}
-ECCVerifyHandle handle;
-
-} // namespace
+void test_init()
+{
+ static ECCVerifyHandle handle;
+}
-FUZZ_TARGET_INIT_HIDDEN(script_assets_test_minimizer, FuzzFrameworkEmptyInitFun, /* hidden */ true)
+FUZZ_TARGET_INIT_HIDDEN(script_assets_test_minimizer, test_init, /* hidden */ true)
{
if (buffer.size() < 2 || buffer.back() != '\n' || buffer[buffer.size() - 2] != ',') return;
const std::string str((const char*)buffer.data(), buffer.size() - 2);
try {
Test(str);
- } catch (const std::runtime_error&) {}
+ } catch (const std::runtime_error&) {
+ }
}
+
+} // namespace