Skip to content

Commit 22770ce

Browse files
committed
Merge bitcoin/bitcoin#31282: refactor: Make node_id a const& in RemoveBlockRequest
fa21f83 ci: Use G++ in valgrind tasks (MarcoFalke) fabd05b refactor: Fix net_processing iwyu includes (MarcoFalke) fa1622d refactor: Make node_id a const& in RemoveBlockRequest (MarcoFalke) Pull request description: Currently, `valgrind` is not usable on a default build with GCC. Specifically, `p2p_compactblocks.py --valgrind` gives a false-positive in `RemoveBlockRequest` when comparing `node_id` with `from_peer`. According to the upstream bug report, this happens because both symbols are on the stack and the compiler can more aggressively optimize the compare (order). See https://bugs.kde.org/show_bug.cgi?id=472329#c7 It is possible to work around this bug by pulling at least one value from the stack. For example, by making `from_peer` a `const` reference. Alternatively, by replacing `auto [node_id, list_it]` with `const auto& [node_id, list_it]`, which is done here. I think this workaround is acceptable, because it does not look like valgrind can trivially fix this. The alternative would be to add a (temporary?) suppression. Fixes bitcoin/bitcoin#27741 Also, fix iwyu includes, while touching this module. Also, switch the CI valgrind scripts to use G++. ACKs for top commit: achow101: ACK fa21f83 TheCharlatan: ACK fa21f83 darosior: utACK fa21f83 ryanofsky: Code review ACK fa21f83. Code changes all look good but I'm a little confused about purpose of the third commit, so left a question about that Tree-SHA512: 7b92cdafd525a5ac53ae2c1a7a92e599bc9b5fd5d315a694b493cd5079ac323d884393b57aa18581b7789247a588c9a27d47698de25b340bc76fc9f1dd1850b4
2 parents 5116655 + fa21f83 commit 22770ce

File tree

5 files changed

+54
-18
lines changed

5 files changed

+54
-18
lines changed

ci/test/00_setup_env_native_fuzz_with_valgrind.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export LC_ALL=C.UTF-8
88

99
export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04"
1010
export CONTAINER_NAME=ci_native_fuzz_valgrind
11-
export PACKAGES="clang-16 llvm-16 libclang-rt-16-dev libevent-dev libboost-dev libsqlite3-dev valgrind"
11+
export PACKAGES="libevent-dev libboost-dev libsqlite3-dev valgrind"
1212
export NO_DEPENDS=1
1313
export RUN_UNIT_TESTS=false
1414
export RUN_FUNCTIONAL_TESTS=false
@@ -17,8 +17,4 @@ export FUZZ_TESTS_CONFIG="--valgrind"
1717
export GOAL="all"
1818
export BITCOIN_CONFIG="\
1919
-DBUILD_FOR_FUZZING=ON \
20-
-DSANITIZERS=fuzzer \
21-
-DCMAKE_C_COMPILER=clang-16 \
22-
-DCMAKE_CXX_COMPILER=clang++-16 \
2320
"
24-
export LLVM_SYMBOLIZER_PATH="/usr/bin/llvm-symbolizer-16"

ci/test/00_setup_env_native_valgrind.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ export LC_ALL=C.UTF-8
88

99
export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04"
1010
export CONTAINER_NAME=ci_native_valgrind
11-
export PACKAGES="valgrind clang-16 llvm-16 libclang-rt-16-dev python3-zmq libevent-dev libboost-dev libdb5.3++-dev libzmq3-dev libsqlite3-dev"
11+
export PACKAGES="valgrind python3-zmq libevent-dev libboost-dev libdb5.3++-dev libzmq3-dev libsqlite3-dev"
1212
export USE_VALGRIND=1
1313
export NO_DEPENDS=1
1414
export TEST_RUNNER_EXTRA="--exclude feature_init,rpc_bind,feature_bind_extra" # feature_init excluded for now, see https://github.com/bitcoin/bitcoin/issues/30011 ; bind tests excluded for now, see https://github.com/bitcoin/bitcoin/issues/17765#issuecomment-602068547
1515
export GOAL="install"
1616
# TODO enable GUI
1717
export BITCOIN_CONFIG="\
1818
-DWITH_ZMQ=ON -DWITH_BDB=ON -DWARN_INCOMPATIBLE_BDB=OFF -DBUILD_GUI=OFF \
19-
-DCMAKE_C_COMPILER=clang-16 \
20-
-DCMAKE_CXX_COMPILER=clang++-16 \
2119
"

contrib/valgrind.supp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
# --error-limit=no build/bin/test_bitcoin
1313
#
1414
# Note that suppressions may depend on OS and/or library versions.
15-
# Tested on:
16-
# * aarch64 (Ubuntu Noble system libs, clang, without gui)
17-
# * x86_64 (Ubuntu Noble system libs, clang, without gui)
15+
# Tested on aarch64 and x86_64 with Ubuntu Noble system libs, using clang-16
16+
# and GCC, without gui.
1817
{
1918
Suppress libdb warning - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=662917
2019
Memcheck:Cond

src/net_processing.cpp

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,82 @@
66
#include <net_processing.h>
77

88
#include <addrman.h>
9+
#include <arith_uint256.h>
910
#include <banman.h>
1011
#include <blockencodings.h>
1112
#include <blockfilter.h>
13+
#include <chain.h>
1214
#include <chainparams.h>
15+
#include <common/bloom.h>
1316
#include <consensus/amount.h>
17+
#include <consensus/params.h>
1418
#include <consensus/validation.h>
19+
#include <core_memusage.h>
20+
#include <crypto/siphash.h>
1521
#include <deploymentstatus.h>
16-
#include <hash.h>
22+
#include <flatfile.h>
1723
#include <headerssync.h>
1824
#include <index/blockfilterindex.h>
1925
#include <kernel/chain.h>
20-
#include <kernel/mempool_entry.h>
2126
#include <logging.h>
2227
#include <merkleblock.h>
28+
#include <net.h>
29+
#include <net_permissions.h>
30+
#include <netaddress.h>
2331
#include <netbase.h>
2432
#include <netmessagemaker.h>
2533
#include <node/blockstorage.h>
34+
#include <node/connection_types.h>
35+
#include <node/protocol_version.h>
2636
#include <node/timeoffsets.h>
2737
#include <node/txdownloadman.h>
2838
#include <node/txreconciliation.h>
2939
#include <node/warnings.h>
40+
#include <policy/feerate.h>
3041
#include <policy/fees.h>
42+
#include <policy/packages.h>
3143
#include <policy/policy.h>
32-
#include <policy/settings.h>
3344
#include <primitives/block.h>
3445
#include <primitives/transaction.h>
46+
#include <protocol.h>
3547
#include <random.h>
3648
#include <scheduler.h>
49+
#include <script/script.h>
50+
#include <serialize.h>
51+
#include <span.h>
3752
#include <streams.h>
3853
#include <sync.h>
3954
#include <tinyformat.h>
4055
#include <txmempool.h>
4156
#include <txorphanage.h>
42-
#include <txrequest.h>
57+
#include <uint256.h>
4358
#include <util/check.h>
4459
#include <util/strencodings.h>
4560
#include <util/time.h>
4661
#include <util/trace.h>
4762
#include <validation.h>
4863

4964
#include <algorithm>
65+
#include <array>
5066
#include <atomic>
67+
#include <compare>
68+
#include <cstddef>
69+
#include <deque>
70+
#include <exception>
71+
#include <functional>
5172
#include <future>
73+
#include <initializer_list>
74+
#include <iterator>
75+
#include <limits>
76+
#include <list>
77+
#include <map>
5278
#include <memory>
5379
#include <optional>
80+
#include <queue>
5481
#include <ranges>
82+
#include <ratio>
83+
#include <set>
84+
#include <span>
5585
#include <typeinfo>
5686
#include <utility>
5787

@@ -1156,7 +1186,7 @@ void PeerManagerImpl::RemoveBlockRequest(const uint256& hash, std::optional<Node
11561186
Assume(mapBlocksInFlight.count(hash) <= MAX_CMPCTBLOCKS_INFLIGHT_PER_BLOCK);
11571187

11581188
while (range.first != range.second) {
1159-
auto [node_id, list_it] = range.first->second;
1189+
const auto& [node_id, list_it]{range.first->second};
11601190

11611191
if (from_peer && *from_peer != node_id) {
11621192
range.first++;

src/net_processing.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
11
// Copyright (c) 2009-2010 Satoshi Nakamoto
2-
// Copyright (c) 2009-2022 The Bitcoin Core developers
2+
// Copyright (c) 2009-present The Bitcoin Core developers
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

66
#ifndef BITCOIN_NET_PROCESSING_H
77
#define BITCOIN_NET_PROCESSING_H
88

9+
#include <consensus/amount.h>
910
#include <net.h>
11+
#include <protocol.h>
12+
#include <threadsafety.h>
1013
#include <txorphanage.h>
1114
#include <validationinterface.h>
1215

16+
#include <atomic>
1317
#include <chrono>
18+
#include <cstdint>
19+
#include <memory>
20+
#include <optional>
21+
#include <string>
22+
#include <vector>
1423

1524
class AddrMan;
16-
class CChainParams;
1725
class CTxMemPool;
1826
class ChainstateManager;
27+
class BanMan;
28+
class CBlockIndex;
29+
class CScheduler;
30+
class DataStream;
31+
class uint256;
1932

2033
namespace node {
2134
class Warnings;

0 commit comments

Comments
 (0)