From fb57e2ddef5763732f5cd0da08fbc5269e8a6f16 Mon Sep 17 00:00:00 2001 From: fanquake Date: Wed, 29 Nov 2023 10:23:46 +0000 Subject: [PATCH 1/3] Merge bitcoin/bitcoin#28966: test: Add missing CBlockPolicyEstimator::processBlockTx suppression fa9dc92c5362431852a9cfe152c6fdb819710eb4 test: Add missing CBlockPolicyEstimator::processBlockTx suppression (MarcoFalke) Pull request description: Fixes https://github.com/bitcoin/bitcoin/pull/28865#discussion_r1408954537 ``` # FUZZ=policy_estimator UBSAN_OPTIONS="suppressions=/root/fuzz_dir/scratch/fuzz_gen/code/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1:report_error_type=1" ./src/test/fuzz/fuzz /tmp/crash-154b42214e70781a9c1ad72d3f2693913dcf8c06 ... policy/fees.cpp:632:27: runtime error: implicit conversion from type 'unsigned int' of value 4294574080 (32-bit, unsigned) to type 'int' changed the value to -393216 (32-bit, signed) #0 0x55cbbe10daee in CBlockPolicyEstimator::processBlockTx(unsigned int, CTxMemPoolEntry const*) src/policy/fees.cpp:632:27 #1 0x55cbbe10e361 in CBlockPolicyEstimator::processBlock(unsigned int, std::vector>&) src/policy/fees.cpp:680:13 #2 0x55cbbd84af48 in policy_estimator_fuzz_target(Span)::$_1::operator()() const src/test/fuzz/policy_estimator.cpp:69:40 #3 0x55cbbd84af48 in unsigned long CallOneOf)::$_0, policy_estimator_fuzz_target(Span)::$_1, policy_estimator_fuzz_target(Span)::$_2, policy_estimator_fuzz_target(Span)::$_3>(FuzzedDataProvider&, policy_estimator_fuzz_target(Span)::$_0, policy_estimator_fuzz_target(Span)::$_1, policy_estimator_fuzz_target(Span)::$_2, policy_estimator_fuzz_target(Span)::$_3) src/./test/fuzz/util.h:43:27 #4 0x55cbbd84af48 in policy_estimator_fuzz_target(Span) src/test/fuzz/policy_estimator.cpp:38:9 #5 0x55cbbda1cc18 in std::function)>::operator()(Span) const /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_function.h:591:9 #6 0x55cbbda1cc18 in LLVMFuzzerTestOneInput src/test/fuzz/fuzz.cpp:178:5 #7 0x55cbbd26a944 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/root/fuzz_dir/scratch/fuzz_gen/code/src/test/fuzz/fuzz+0x190e944) (BuildId: ffb89e0b86c093ca3bdeae6f85537737a4e3b42d) #8 0x55cbbd253916 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) (/root/fuzz_dir/scratch/fuzz_gen/code/src/test/fuzz/fuzz+0x18f7916) (BuildId: ffb89e0b86c093ca3bdeae6f85537737a4e3b42d) #9 0x55cbbd25945a in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/root/fuzz_dir/scratch/fuzz_gen/code/src/test/fuzz/fuzz+0x18fd45a) (BuildId: ffb89e0b86c093ca3bdeae6f85537737a4e3b42d) #10 0x55cbbd284026 in main (/root/fuzz_dir/scratch/fuzz_gen/code/src/test/fuzz/fuzz+0x1928026) (BuildId: ffb89e0b86c093ca3bdeae6f85537737a4e3b42d) #11 0x7fe4aa8280cf (/lib/x86_64-linux-gnu/libc.so.6+0x280cf) (BuildId: 96ab1a8f3b2c9a2ed37c7388615e6a726d037e89) #12 0x7fe4aa828188 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x28188) (BuildId: 96ab1a8f3b2c9a2ed37c7388615e6a726d037e89) #13 0x55cbbd24e494 in _start (/root/fuzz_dir/scratch/fuzz_gen/code/src/test/fuzz/fuzz+0x18f2494) (BuildId: ffb89e0b86c093ca3bdeae6f85537737a4e3b42d) SUMMARY: UndefinedBehaviorSanitizer: implicit-integer-sign-change policy/fees.cpp:632:27 in ``` ``` # base64 /tmp/crash-154b42214e70781a9c1ad72d3f2693913dcf8c06 AQEAAAAAADkFlVwAAQEAAAAAADkFlZVcACTDSSsP3746IAZrH48khwMAAQEB/QEALQAACwAAAAAA FgAAAAAAAQAABgAAAAAAAAAAAAAAAAAAACcQAAAAAAAAAAAAAAAAAAAAAAD6AAAAOQWVXAABAQAA AAAAOQWVlVwAIMNJKw/fvjogBmsfjySHAwABAQH9AQAtAAALAAAAAAAAAAABAAAGAAAAAAAAAAAA AAAAAAAAJxAAAAAAAAAAAAAAAAAAAAAAAPr/AAAAAAAAAAAAAAQAAAAA/wAAAAAAAAAAAAAEAAAA AAEBAeAIAVwBXAAA/jbSBvwBKABSKBwBYgEB2wAEkvXInHYAAAAAAAAAvgAAAAAA/9//6v8e/xIk MgAlAiUAOw== ACKs for top commit: fanquake: ACK fa9dc92c5362431852a9cfe152c6fdb819710eb4 dergoegge: utACK fa9dc92c5362431852a9cfe152c6fdb819710eb4 Tree-SHA512: 3898c17c928ecc2bcc8c7086359e9ae00da2197b4d8e10c7bf6d12415326c9bca3ef6e1d8d3b83172ccfa604ce7e7371415262ba705225f9ea4da8b1a7eb0306 Signed-off-by: Shailendra Kumar Gupta --- test/sanitizer_suppressions/ubsan | 1 + 1 file changed, 1 insertion(+) diff --git a/test/sanitizer_suppressions/ubsan b/test/sanitizer_suppressions/ubsan index 1d1f2ad352b5..b2268035bc0f 100644 --- a/test/sanitizer_suppressions/ubsan +++ b/test/sanitizer_suppressions/ubsan @@ -52,6 +52,7 @@ unsigned-integer-overflow:EvalScript unsigned-integer-overflow:txmempool.cpp unsigned-integer-overflow:util/strencodings.cpp unsigned-integer-overflow:xoroshiro128plusplus.h +implicit-integer-sign-change:CBlockPolicyEstimator::processBlockTx implicit-integer-sign-change:addrman.h implicit-integer-sign-change:bech32.cpp implicit-integer-sign-change:compat/stdin.cpp From 1be3b9541ded5e608ab9be486c3a43aa88fa81b2 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 7 Mar 2024 12:41:44 +0000 Subject: [PATCH 2/3] Merge bitcoin-core/gui#803: test: Set organization name 0dcbad341b0a8420a899c6dce0db56dd0deaa036 qt, test: Clean settings after tests (Hennadii Stepanov) 49cf63522e202caf326bad161ff6fa05d1076566 qt, test: Set organization name (Hennadii Stepanov) Pull request description: From Qt [docs](https://doc.qt.io/qt-5/qsettings.html#QSettings-4): > If [`QCoreApplication::setOrganizationName()`](https://doc.qt.io/qt-5/qcoreapplication.html#organizationName-prop) and [`QCoreApplication::setApplicationName()`](https://doc.qt.io/qt-5/qcoreapplication.html#applicationName-prop) has not been previously called, the `QSettings` object will not be able to read or write any settings, and [`status()`](https://doc.qt.io/qt-5/qsettings.html#status) will return [`AccessError`](https://doc.qt.io/qt-5/qsettings.html#Status-enum). Fixes https://github.com/bitcoin-core/gui/issues/799. ACKs for top commit: pablomartin4btc: utACK 0dcbad341b0a8420a899c6dce0db56dd0deaa036 Tree-SHA512: d5ac160f17cc358f0c1b89097193cd5adfd25f5531955c211f3e0994fc084e0a2b8d3aeddebe38f3a8ab5333edef5aa92b18915885c9e58b33f2e5786f31c600 --- src/qt/test/optiontests.cpp | 11 +++++++++ src/qt/test/test_main.cpp | 49 +++++++++++++++++++++++-------------- 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/src/qt/test/optiontests.cpp b/src/qt/test/optiontests.cpp index 17ffeb220b69..3db9c4e6a6a0 100644 --- a/src/qt/test/optiontests.cpp +++ b/src/qt/test/optiontests.cpp @@ -46,6 +46,17 @@ void OptionTests::migrateSettings() settings.sync(); + QVERIFY(settings.contains("nDatabaseCache")); + QVERIFY(settings.contains("nThreadsScriptVerif")); + QVERIFY(settings.contains("fUseUPnP")); + QVERIFY(settings.contains("fListen")); + QVERIFY(settings.contains("bPrune")); + QVERIFY(settings.contains("nPruneSize")); + QVERIFY(settings.contains("fUseProxy")); + QVERIFY(settings.contains("addrProxy")); + QVERIFY(settings.contains("fUseSeparateProxyTor")); + QVERIFY(settings.contains("addrSeparateProxyTor")); + OptionsModel options{m_node}; bilingual_str error; QVERIFY(options.Init(error)); diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp index 466c347c19fb..67c52db1c8af 100644 --- a/src/qt/test/test_main.cpp +++ b/src/qt/test/test_main.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -25,6 +26,7 @@ #include #include #include +#include #include #include @@ -81,38 +83,47 @@ int main(int argc, char* argv[]) setenv("QT_QPA_PLATFORM", "minimal", 0 /* overwrite */); #endif - BitcoinApplication app; - app.setApplicationName("Dash-Qt-test"); - app.createNode(*init); + + QCoreApplication::setOrganizationName(QAPP_ORG_NAME); + QCoreApplication::setApplicationName(QAPP_APP_NAME_DEFAULT "-test"); int num_test_failures{0}; - AppTests app_tests(app); - num_test_failures += QTest::qExec(&app_tests); + { + BitcoinApplication app; + app.createNode(*init); + + AppTests app_tests(app); + num_test_failures += QTest::qExec(&app_tests); - OptionTests options_tests(app.node()); - num_test_failures += QTest::qExec(&options_tests); + OptionTests options_tests(app.node()); + num_test_failures += QTest::qExec(&options_tests); - URITests test1; - num_test_failures += QTest::qExec(&test1); + URITests test1; + num_test_failures += QTest::qExec(&test1); - RPCNestedTests test3(app.node()); - num_test_failures += QTest::qExec(&test3); + RPCNestedTests test3(app.node()); + num_test_failures += QTest::qExec(&test3); #ifdef ENABLE_WALLET - WalletTests test5(app.node()); - num_test_failures += QTest::qExec(&test5); + WalletTests test5(app.node()); + num_test_failures += QTest::qExec(&test5); - AddressBookTests test6(app.node()); - num_test_failures += QTest::qExec(&test6); + AddressBookTests test6(app.node()); + num_test_failures += QTest::qExec(&test6); #endif TrafficGraphDataTests test7; num_test_failures += QTest::qExec(&test7); - if (num_test_failures) { - qWarning("\nFailed tests: %d\n", num_test_failures); - } else { - qDebug("\nAll tests passed.\n"); + if (num_test_failures) { + qWarning("\nFailed tests: %d\n", num_test_failures); + } else { + qDebug("\nAll tests passed.\n"); + } } + + QSettings settings; + settings.clear(); + return num_test_failures; } From f5dec3bce1ad9dea7772d0170f6d885456cba8f2 Mon Sep 17 00:00:00 2001 From: fanquake Date: Mon, 3 Apr 2023 14:20:35 +0100 Subject: [PATCH 3/3] Merge bitcoin/bitcoin#27254: refactor: Extract util/fs from util/system 00e9b97f37e0bdf4c647236838c10b68b7ad5be3 refactor: Move fs.* to util/fs.* (TheCharlatan) 106b46d9d25b5228ef009fbbe6f9a7ae35090d15 Add missing fs.h includes (TheCharlatan) b202b3dd6393b415fa68e18dc49c9431dc6b58b2 Add missing cstddef include in assumptions.h (TheCharlatan) 18fb36367a28819bd5ab402344802796a1248979 refactor: Extract util/fs_helpers from util/system (Ben Woosley) Pull request description: This pull request is part of the `libbitcoinkernel` project https://github.com/bitcoin/bitcoin/issues/24303 https://github.com/bitcoin/bitcoin/projects/18 and more specifically its "Step 2: Decouple most non-consensus code from libbitcoinkernel". This commit was originally authored by empact and is taken from its parent PR #25152. #### Context There is an ongoing effort to decouple the `ArgsManager` used for command line parsing user-provided arguments from the libbitcoinkernel library (https://github.com/bitcoin/bitcoin/pull/25290, https://github.com/bitcoin/bitcoin/pull/25487, https://github.com/bitcoin/bitcoin/pull/25527, https://github.com/bitcoin/bitcoin/pull/25862, https://github.com/bitcoin/bitcoin/pull/26177, and https://github.com/bitcoin/bitcoin/pull/27125). The `ArgsManager` is defined in `system.h`. A similar pull request extracting functionality from `system.h` has been merged in https://github.com/bitcoin/bitcoin/pull/27238. #### Changes Next to providing better code organization, this PR removes some reliance of the tree of libbitcoinkernel header includes on `system.h` (and thus the `ArgsManager` definition) by moving filesystem related functions out of the `system.*` files. There is already a pair of `fs.h` / `fs.cpp` in the top-level `src/` directory. They were not combined with the files introduced here, to keep the patch cleaner and more importantly because they are often included without the utility functions. The new files are therefore named `fs_helpers` and the existing `fs` files are moved into the util directory. Further commits splitting more functionality out of `system.h` are still in #25152 and will be submitted in separate PRs once this PR has been processed. ACKs for top commit: hebasto: ACK 00e9b97f37e0bdf4c647236838c10b68b7ad5be3 Tree-SHA512: 31422f148d14ba3c843b99b1550a6fd77c77f350905ca324f93d4f97b652246bc58fa9696c64d1201979cf88733e40be02d262739bb7d417cf22bf506fdb7666 --- src/Makefile.am | 6 +- src/addrdb.cpp | 3 +- src/addrdb.h | 2 +- src/banman.h | 2 +- src/bench/bench.cpp | 2 +- src/bench/bench.h | 2 +- src/bench/bench_bitcoin.cpp | 2 +- src/bitcoin-tx.cpp | 2 +- src/coinjoin/client.cpp | 2 +- src/dbwrapper.cpp | 3 +- src/dbwrapper.h | 2 +- src/flat-database.h | 2 +- src/flatfile.cpp | 2 +- src/flatfile.h | 2 +- src/i2p.cpp | 2 +- src/i2p.h | 2 +- src/index/blockfilterindex.cpp | 1 + src/init.cpp | 3 +- src/init/common.cpp | 2 +- src/interfaces/wallet.h | 2 +- src/ipc/interfaces.cpp | 2 +- src/ipc/process.cpp | 2 +- src/ipc/process.h | 2 + src/logging.cpp | 2 +- src/logging.h | 2 +- src/net.cpp | 2 +- src/net.h | 2 +- src/node/blockstorage.cpp | 2 +- src/node/blockstorage.h | 2 +- src/policy/fees.cpp | 2 +- src/policy/fees.h | 1 + src/qt/bitcoin.cpp | 2 +- src/qt/guiutil.cpp | 3 +- src/qt/guiutil.h | 2 +- src/qt/intro.cpp | 3 +- src/qt/psbtoperationsdialog.cpp | 2 +- src/qt/walletframe.cpp | 3 +- src/rpc/blockchain.cpp | 2 +- src/rpc/blockchain.h | 2 +- src/rpc/mempool.cpp | 2 +- src/rpc/request.cpp | 3 +- src/stacktraces.cpp | 2 +- src/test/argsman_tests.cpp | 6 +- src/test/fs_tests.cpp | 3 +- src/test/fuzz/banman.cpp | 2 +- src/test/fuzz/fuzz.cpp | 2 +- src/test/fuzz/utxo_snapshot.cpp | 1 + src/test/script_tests.cpp | 1 + src/test/settings_tests.cpp | 2 +- src/test/streams_tests.cpp | 2 +- src/test/util/chainstate.h | 2 +- src/test/util/setup_common.h | 2 +- src/test/util_tests.cpp | 6 +- src/torcontrol.h | 2 +- src/util/asmap.cpp | 2 +- src/util/asmap.h | 2 +- src/{ => util}/fs.cpp | 2 +- src/{ => util}/fs.h | 6 +- src/util/fs_helpers.cpp | 296 ++++++++++++++++++++++++++ src/util/fs_helpers.h | 63 ++++++ src/util/getuniquepath.cpp | 2 +- src/util/getuniquepath.h | 2 +- src/util/readwritefile.cpp | 2 +- src/util/readwritefile.h | 2 +- src/util/settings.cpp | 2 +- src/util/settings.h | 2 +- src/util/system.cpp | 241 +-------------------- src/util/system.h | 47 +--- src/validation.cpp | 1 + src/validation.h | 2 +- src/wallet/bdb.cpp | 3 +- src/wallet/bdb.h | 2 +- src/wallet/db.cpp | 2 +- src/wallet/db.h | 2 +- src/wallet/dump.cpp | 2 +- src/wallet/dump.h | 2 +- src/wallet/load.cpp | 2 +- src/wallet/rpc/backup.cpp | 2 +- src/wallet/salvage.cpp | 2 +- src/wallet/salvage.h | 2 +- src/wallet/sqlite.cpp | 2 +- src/wallet/test/db_tests.cpp | 2 +- src/wallet/test/init_test_fixture.cpp | 2 +- src/wallet/wallet.cpp | 3 +- src/wallet/wallet.h | 2 +- src/wallet/walletdb.cpp | 2 +- src/wallet/wallettool.cpp | 2 +- src/wallet/walletutil.h | 2 +- 88 files changed, 466 insertions(+), 370 deletions(-) rename src/{ => util}/fs.cpp (99%) rename src/{ => util}/fs.h (99%) create mode 100644 src/util/fs_helpers.cpp create mode 100644 src/util/fs_helpers.h diff --git a/src/Makefile.am b/src/Makefile.am index a0eca537b48d..99627e98a932 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -244,7 +244,6 @@ BITCOIN_CORE_H = \ gsl/pointers.h \ flat-database.h \ flatfile.h \ - fs.h \ httprpc.h \ httpserver.h \ i2p.h \ @@ -398,6 +397,8 @@ BITCOIN_CORE_H = \ util/error.h \ util/fastrange.h \ util/fees.h \ + util/fs.h \ + util/fs_helpers.h \ util/golombrice.h \ util/hasher.h \ util/hash_type.h \ @@ -978,7 +979,6 @@ libbitcoin_util_a_SOURCES = \ support/lockedpool.cpp \ chainparamsbase.cpp \ clientversion.cpp \ - fs.cpp \ interfaces/echo.cpp \ interfaces/handler.cpp \ interfaces/init.cpp \ @@ -996,6 +996,8 @@ libbitcoin_util_a_SOURCES = \ util/edge.cpp \ util/error.cpp \ util/fees.cpp \ + util/fs.cpp \ + util/fs_helpers.cpp \ util/hasher.cpp \ util/getuniquepath.cpp \ util/sock.cpp \ diff --git a/src/addrdb.cpp b/src/addrdb.cpp index 83bc6192ff7b..823bbc7fe009 100644 --- a/src/addrdb.cpp +++ b/src/addrdb.cpp @@ -8,7 +8,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/src/addrdb.h b/src/addrdb.h index 911b791b7170..2d71f7456e74 100644 --- a/src/addrdb.h +++ b/src/addrdb.h @@ -6,9 +6,9 @@ #ifndef BITCOIN_ADDRDB_H #define BITCOIN_ADDRDB_H -#include #include // For banmap_t #include +#include #include #include diff --git a/src/banman.h b/src/banman.h index c968fd99a2c0..77d78966a58d 100644 --- a/src/banman.h +++ b/src/banman.h @@ -7,9 +7,9 @@ #include #include -#include #include // For banmap_t #include +#include #include #include diff --git a/src/bench/bench.cpp b/src/bench/bench.cpp index ae017833ce6b..de8eacfa9570 100644 --- a/src/bench/bench.cpp +++ b/src/bench/bench.cpp @@ -4,8 +4,8 @@ #include -#include #include +#include #include #include diff --git a/src/bench/bench.h b/src/bench/bench.h index 63e1bf67e21e..d3fba1e28c41 100644 --- a/src/bench/bench.h +++ b/src/bench/bench.h @@ -5,7 +5,7 @@ #ifndef BITCOIN_BENCH_BENCH_H #define BITCOIN_BENCH_BENCH_H -#include +#include #include #include diff --git a/src/bench/bench_bitcoin.cpp b/src/bench/bench_bitcoin.cpp index 4db5412e16d6..c34949264cc2 100644 --- a/src/bench/bench_bitcoin.cpp +++ b/src/bench/bench_bitcoin.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index a1dfb9e7d374..47b569f1ae19 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include