Skip to content

Commit ed5c410

Browse files
Merge dashpay#6802: backport: 0.25 batch 587
9e0f19f Merge bitcoin#28512: doc: Be vague instead of wrong about MALLOC_ARENA_MAX (PastaBot) d04979f Merge bitcoin#29821: fuzz: Some `test/fuzz/test_runner.py` improvements (PastaBot) c9ffe01 Merge bitcoin#27423: ci: fix git dubious permissions error (PastaBot) d4b420f Merge bitcoin#29805: test: Fix debug recommendation in argsman_tests (PastaBot) 78a5017 Merge bitcoin#29776: ThreadSanitizer: Fix bitcoin#29767 (PastaBot) 6c24671 Merge bitcoin#29687: cli: improve bitcoin-cli error when not connected (PastaBot) 4f1d6e7 Merge bitcoin#29764: doc: Suggest installing dev packages for debian/ubuntu qt5 build (PastaBot) 6a5e1c2 Merge bitcoin#29094: ci: Better tidy errors (PastaBot) 08eb23b Merge bitcoin#27919: ci: Run fuzz target even if input folder is empty (PastaBot) Pull request description: ## Issue being fixed or feature implemented batch of backports ## What was done? ## How Has This Been Tested? ## Breaking Changes ## Checklist: _Go over all the following points, and put an `x` in all the boxes that apply._ - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: knst: utACK 9e0f19f Tree-SHA512: 1c16cd9402cec0490df96044e98a33e87b221a162885ad3bf87ef641af9cbd5fa9a7179bc13fccf6ff14cf22ba967fc8f992e5c9cc486fc04287a50bcd16579c
2 parents 588a6e0 + 9e0f19f commit ed5c410

File tree

8 files changed

+47
-21
lines changed

8 files changed

+47
-21
lines changed

ci/dash/lint-tidy.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ set -eo pipefail
1212
# that *before* running this script.
1313

1414
cd "${BASE_ROOT_DIR}/build-ci/dashcore-${BUILD_TARGET}/src"
15-
( run-clang-tidy -quiet "${MAKEJOBS}" ) | grep -C5 "error"
15+
if ! ( run-clang-tidy -quiet "${MAKEJOBS}" | tee tmp.tidy-out.txt ); then
16+
grep -C5 "error: " tmp.tidy-out.txt
17+
echo "^^^ ⚠️ Failure generated from clang-tidy"
18+
false
19+
fi
1620

1721
cd "${BASE_ROOT_DIR}/build-ci/dashcore-${BUILD_TARGET}"
1822
iwyu_tool.py \

ci/test/04_install.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
6161
docker exec "$DOCKER_ID" chown -R "$LOCAL_USER":"$LOCAL_USER" "${BASE_ROOT_DIR}"
6262
export DOCKER_CI_CMD_PREFIX_ROOT="docker exec -u 0 $DOCKER_ID"
6363
export DOCKER_CI_CMD_PREFIX="docker exec -u $LOCAL_UID $DOCKER_ID"
64+
# Fixes permission issues when there is a container UID/GID mismatch with the owner
65+
# of the mounted dash src dir.
66+
$DOCKER_CI_CMD_PREFIX_ROOT git config --global --add safe.directory "*"
6467
else
6568
echo "Running on host system without docker wrapper"
6669
fi

doc/build-unix.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ To build without GUI pass `--without-gui`.
107107
To build with Qt 5 you need the following:
108108

109109
```sh
110-
sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools
110+
sudo apt-get install qtbase5-dev qttools5-dev qttools5-dev-tools
111111
```
112112

113113
Additionally, to support Wayland protocol for modern desktop environments:

doc/reduce-memory.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ threads take up 8MiB for the thread stack on a 64-bit system, and 4MiB in a
4343

4444
## Linux specific
4545

46-
By default, since glibc `2.10`, the C library will create up to two heap arenas per core. This is known to cause excessive memory usage in some scenarios. To avoid this make a script that sets `MALLOC_ARENA_MAX` before starting dashd:
46+
By default, glibc's implementation of `malloc` may use more than one arena. This is known to cause excessive memory usage in some scenarios. To avoid this, make a script that sets `MALLOC_ARENA_MAX` before starting dashd:
4747

4848
```bash
4949
#!/usr/bin/env bash

src/bitcoin-cli.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,10 @@ static UniValue CallRPC(BaseRequestHandler* rh, const std::string& strMethod, co
828828
if (response.error != -1) {
829829
responseErrorMessage = strprintf(" (error code %d - \"%s\")", response.error, http_errorstring(response.error));
830830
}
831-
throw CConnectionFailed(strprintf("Could not connect to the server %s:%d%s\n\nMake sure the dashd server is running and that you are connecting to the correct RPC port.", host, port, responseErrorMessage));
831+
throw CConnectionFailed(strprintf("Could not connect to the server %s:%d%s\n\n"
832+
"Make sure the dashd server is running and that you are connecting to the correct RPC port.\n"
833+
"Use \"dash-cli -help\" for more info.",
834+
host, port, responseErrorMessage));
832835
} else if (response.status == HTTP_UNAUTHORIZED) {
833836
if (failedToGetAuthCookie) {
834837
throw std::runtime_error(strprintf(

src/index/base.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ void BaseIndex::ThreadSync()
151151
const CBlockIndex* pindex_next = NextSyncBlock(pindex, m_chainstate->m_chain);
152152
if (!pindex_next) {
153153
SetBestBlockIndex(pindex);
154-
m_synced = true;
155154
// No need to handle errors in Commit. See rationale above.
156155
Commit();
156+
m_synced = true;
157157
break;
158158
}
159159
if (pindex_next->pprev != pindex && !Rewind(pindex, pindex_next->pprev)) {

src/test/argsman_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ BOOST_FIXTURE_TEST_CASE(util_ArgsMerge, ArgsMergeTestingSetup)
903903

904904
// If check below fails, should manually dump the results with:
905905
//
906-
// ARGS_MERGE_TEST_OUT=results.txt ./test_dash --run_test=util_tests/util_ArgsMerge
906+
// ARGS_MERGE_TEST_OUT=results.txt ./test_dash --run_test=argsman_tests/util_ArgsMerge
907907
//
908908
// And verify diff against previous results to make sure the changes are expected.
909909
//
@@ -1006,7 +1006,7 @@ BOOST_FIXTURE_TEST_CASE(util_ChainMerge, ChainMergeTestingSetup)
10061006

10071007
// If check below fails, should manually dump the results with:
10081008
//
1009-
// CHAIN_MERGE_TEST_OUT=results.txt ./test_dash --run_test=util_tests/util_ChainMerge
1009+
// CHAIN_MERGE_TEST_OUT=results.txt ./test_dash --run_test=argsman_tests/util_ChainMerge
10101010
//
10111011
// And verify diff against previous results to make sure the changes are expected.
10121012
//

test/fuzz/test_runner.py

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77

88
from concurrent.futures import ThreadPoolExecutor, as_completed
9+
from pathlib import Path
910
import argparse
1011
import configparser
1112
import logging
@@ -41,6 +42,11 @@ def main():
4142
action='store_true',
4243
help='If true, run fuzzing binaries under the valgrind memory error detector',
4344
)
45+
parser.add_argument(
46+
"--empty_min_time",
47+
type=int,
48+
help="If set, run at least this long, if the existing fuzz inputs directory is empty.",
49+
)
4450
parser.add_argument(
4551
'-x',
4652
'--exclude',
@@ -76,6 +82,7 @@ def main():
7682
)
7783

7884
args = parser.parse_args()
85+
args.corpus_dir = Path(args.corpus_dir)
7986

8087
# Set up logging
8188
logging.basicConfig(
@@ -92,9 +99,11 @@ def main():
9299
logging.error("Must have fuzz targets built")
93100
sys.exit(1)
94101

102+
fuzz_bin=os.getenv("DASHFUZZ", default=os.path.join(config["environment"]["BUILDDIR"], 'src', 'test', 'fuzz', 'fuzz'))
103+
95104
# Build list of tests
96105
test_list_all = parse_test_list(
97-
fuzz_bin=os.path.join(config["environment"]["BUILDDIR"], 'src', 'test', 'fuzz', 'fuzz'),
106+
fuzz_bin=fuzz_bin,
98107
source_dir=config['environment']['SRCDIR'],
99108
)
100109

@@ -139,7 +148,7 @@ def main():
139148
try:
140149
help_output = subprocess.run(
141150
args=[
142-
os.path.join(config["environment"]["BUILDDIR"], 'src', 'test', 'fuzz', 'fuzz'),
151+
fuzz_bin,
143152
'-help=1',
144153
],
145154
env=get_fuzz_env(target=test_list_selection[0], source_dir=config['environment']['SRCDIR']),
@@ -160,7 +169,7 @@ def main():
160169
return generate_corpus(
161170
fuzz_pool=fuzz_pool,
162171
src_dir=config['environment']['SRCDIR'],
163-
build_dir=config["environment"]["BUILDDIR"],
172+
fuzz_bin=fuzz_bin,
164173
corpus_dir=args.corpus_dir,
165174
targets=test_list_selection,
166175
)
@@ -171,7 +180,7 @@ def main():
171180
corpus=args.corpus_dir,
172181
test_list=test_list_selection,
173182
src_dir=config['environment']['SRCDIR'],
174-
build_dir=config["environment"]["BUILDDIR"],
183+
fuzz_bin=fuzz_bin,
175184
merge_dir=args.m_dir,
176185
)
177186
return
@@ -181,12 +190,13 @@ def main():
181190
corpus=args.corpus_dir,
182191
test_list=test_list_selection,
183192
src_dir=config['environment']['SRCDIR'],
184-
build_dir=config["environment"]["BUILDDIR"],
193+
fuzz_bin=fuzz_bin,
185194
use_valgrind=args.valgrind,
195+
empty_min_time=args.empty_min_time,
186196
)
187197

188198

189-
def generate_corpus(*, fuzz_pool, src_dir, build_dir, corpus_dir, targets):
199+
def generate_corpus(*, fuzz_pool, src_dir, fuzz_bin, corpus_dir, targets):
190200
"""Generates new corpus.
191201
192202
Run {targets} without input, and outputs the generated corpus to
@@ -212,7 +222,7 @@ def job(command, t):
212222
os.makedirs(target_corpus_dir, exist_ok=True)
213223
use_value_profile = int(random.random() < .3)
214224
command = [
215-
os.path.join(build_dir, 'src', 'test', 'fuzz', 'fuzz'),
225+
fuzz_bin,
216226
"-rss_limit_mb=8000",
217227
"-max_total_time=6000",
218228
"-reload=0",
@@ -225,12 +235,12 @@ def job(command, t):
225235
future.result()
226236

227237

228-
def merge_inputs(*, fuzz_pool, corpus, test_list, src_dir, build_dir, merge_dir):
238+
def merge_inputs(*, fuzz_pool, corpus, test_list, src_dir, fuzz_bin, merge_dir):
229239
logging.info("Merge the inputs from the passed dir into the corpus_dir. Passed dir {}".format(merge_dir))
230240
jobs = []
231241
for t in test_list:
232242
args = [
233-
os.path.join(build_dir, 'src', 'test', 'fuzz', 'fuzz'),
243+
fuzz_bin,
234244
'-rss_limit_mb=8000',
235245
'-set_cover_merge=1',
236246
# set_cover_merge is used instead of -merge=1 to reduce the overall
@@ -263,16 +273,22 @@ def job(t, args):
263273
future.result()
264274

265275

266-
def run_once(*, fuzz_pool, corpus, test_list, src_dir, build_dir, use_valgrind):
276+
def run_once(*, fuzz_pool, corpus, test_list, src_dir, fuzz_bin, use_valgrind, empty_min_time):
267277
jobs = []
268278
for t in test_list:
269-
corpus_path = os.path.join(corpus, t)
279+
corpus_path = corpus / t
270280
os.makedirs(corpus_path, exist_ok=True)
271281
args = [
272-
os.path.join(build_dir, 'src', 'test', 'fuzz', 'fuzz'),
273-
'-runs=1',
274-
corpus_path,
282+
fuzz_bin,
275283
]
284+
empty_dir = not any(corpus_path.iterdir())
285+
if empty_min_time and empty_dir:
286+
args += [f"-max_total_time={empty_min_time}"]
287+
else:
288+
args += [
289+
"-runs=1",
290+
corpus_path,
291+
]
276292
if use_valgrind:
277293
args = ['valgrind', '--quiet', '--error-exitcode=1'] + args
278294

0 commit comments

Comments
 (0)