I’ve been using this branch for some time, for working Valgrind CI jobs on aarch64. Benefits include:
- Valgrind CI jobs work across x86_64 & aarch64.
- Can use latest (hopefully less buggy) Valgrind, rather than whatever the distro happens to package.
- No need to “bless” a specific compiler, (current discussion includes switching from Clang to GCC as a workaround).
- Valgrind from source runs significantly faster compared to the system package. i.e, when fuzzing under valgrind:
Master:
0asmap_direct with args
1Done 646 runs in 155 second(s)
2....
3addrman_deserialize with args
4Done 2944 runs in 2875 second(s)
vs running this branch:
0asmap_direct with args
1Done 646 runs in 23 second(s)
2...
3addrman_deserialize with args
4Done 2944 runs in 413 second(s)
This is also being seen in the qa-assets repo: https://github.com/bitcoin-core/qa-assets/pull/136#issuecomment-1611072317.
For example, the tx_pool_standard
target under Valgrind currently takes > 10 hours to complete:
0Run tx_pool_standard with args ['valgrind', '--quiet', '--error-exitcode=1', '/tmp/cirrus-build/bitcoin-core/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz', '-runs=1', PosixPath('/tmp/cirrus-build/bitcoin-core/ci/scratch/qa-assets/fuzz_seed_corpus/tx_pool_standard')]INFO: Running with entropic power schedule (0xFF, 100).
1INFO: Seed: 242510469
2INFO: Loaded 1 modules (248538 inline 8-bit counters): 248538 [0x27fd278, 0x2839d52),
3INFO: Loaded 1 PC tables (248538 PCs): 248538 [0x2839d58,0x2c04af8),
4INFO: 3775 files found in /tmp/cirrus-build/bitcoin-core/ci/scratch/qa-assets/fuzz_seed_corpus/tx_pool_standard
5INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 1048576 bytes
6INFO: seed corpus: files: 3775 min: 1b max: 2090089b total: 88593805b rss: 321Mb
7[#16](/bitcoin-bitcoin/16/) pulse cov: 4536 ft: 4537 corp: 1/1b exec/s: 5 rss: 323Mb
8[#32](/bitcoin-bitcoin/32/) pulse cov: 4538 ft: 4544 corp: 4/10b exec/s: 6 rss: 323Mb
9[#64](/bitcoin-bitcoin/64/) pulse cov: 4540 ft: 4553 corp: 8/34b exec/s: 6 rss: 323Mb
10[#128](/bitcoin-bitcoin/128/) pulse cov: 6319 ft: 9483 corp: 21/196b exec/s: 4 rss: 327Mb
11[#256](/bitcoin-bitcoin/256/) pulse cov: 6339 ft: 13188 corp: 104/1621b exec/s: 2 rss: 327Mb
12[#512](/bitcoin-bitcoin/512/) pulse cov: 8952 ft: 24180 corp: 262/6023b exec/s: 2 rss: 335Mb
13[#1024](/bitcoin-bitcoin/1024/) pulse cov: 9924 ft: 36577 corp: 575/23Kb exec/s: 1 rss: 343Mb
14<snip>
15[#2048](/bitcoin-bitcoin/2048/) pulse cov: 10161 ft: 56438 corp: 1218/244Kb exec/s: 0 rss: 371Mb
16<snip>
17[#3776](/bitcoin-bitcoin/3776/) INITED cov: 10988 ft: 65398 corp: 1933/10331Kb exec/s: 0 rss: 430Mb
18[#3776](/bitcoin-bitcoin/3776/) DONE cov: 10988 ft: 65398 corp: 1933/10331Kb lim: 1048576 exec/s: 0 rss: 430Mb
19Done 3776 runs in 37778 second(s)
however with this branch, it takes 1.5 hours:
0Run tx_pool_standard with args ['valgrind', '--quiet', '--error-exitcode=1', '/tmp/cirrus-build-1174734651/bitcoin-core/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz', '-runs=1', PosixPath('/tmp/cirrus-build-1174734651/bitcoin-core/ci/scratch/qa-assets/fuzz_seed_corpus/tx_pool_standard')]INFO: Running with entropic power schedule (0xFF, 100).
1INFO: Seed: 350811728
2INFO: Loaded 1 modules (366489 inline 8-bit counters): 366489 [0x1c106d0, 0x1c69e69),
3INFO: Loaded 1 PC tables (366489 PCs): 366489 [0x1c69e70,0x2201800),
4INFO: 3775 files found in /tmp/cirrus-build-1174734651/bitcoin-core/ci/scratch/qa-assets/fuzz_seed_corpus/tx_pool_standard
5INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 1048576 bytes
6INFO: seed corpus: files: 3775 min: 1b max: 2090089b total: 88593805b rss: 302Mb
7[#64](/bitcoin-bitcoin/64/) pulse cov: 1172 ft: 1186 corp: 11/47b exec/s: 32 rss: 304Mb
8[#128](/bitcoin-bitcoin/128/) pulse cov: 1793 ft: 2253 corp: 32/285b exec/s: 32 rss: 304Mb
9[#256](/bitcoin-bitcoin/256/) pulse cov: 1862 ft: 3792 corp: 99/1399b exec/s: 19 rss: 305Mb
10[#512](/bitcoin-bitcoin/512/) pulse cov: 3074 ft: 7764 corp: 221/4862b exec/s: 15 rss: 308Mb
11[#1024](/bitcoin-bitcoin/1024/) pulse cov: 3767 ft: 12721 corp: 498/20Kb exec/s: 10 rss: 314Mb
12[#2048](/bitcoin-bitcoin/2048/) pulse cov: 4141 ft: 22302 corp: 1101/224Kb exec/s: 5 rss: 341Mb
13<snip>
14[#3776](/bitcoin-bitcoin/3776/) INITED cov: 4573 ft: 26452 corp: 1737/6505Kb exec/s: 0 rss: 400Mb
15[#3776](/bitcoin-bitcoin/3776/) DONE cov: 4573 ft: 26452 corp: 1737/6505Kb lim: 698384 exec/s: 0 rss: 400Mb
16Done 3776 runs in 5163 second(s)
Running the native_valgrind CI (master, aarch64):
0test/sighash_tests.cpp(120): Entering test case "sighash_test"
1==21957== Source and destination overlap in memcpy(0x871e4b0, 0x871e4b0, 36)
2==21957== at 0x488CFA0: __GI_memcpy (in /usr/libexec/valgrind/vgpreload_memcheck-arm64-linux.so)
3==21957== by 0x8F7F63: CTxIn::operator=(CTxIn const&) (transaction.h:74)
4==21957== by 0x93F96B: SignatureHashOld(CScript, CTransaction const&, unsigned int, int) (sighash_tests.cpp:76)
5==21957== by 0x93EF1F: sighash_tests::sighash_test::test_method() (sighash_tests.cpp:138)
6==21957== by 0x93EB73: sighash_tests::sighash_test_invoker() (sighash_tests.cpp:120)
7==21957== by 0x36CF47: boost::detail::function::void_function_invoker0<void (*)(), void>::invoke(boost::detail::function::function_buffer&) (function_template.hpp:117)
8==21957== by 0x25B367: boost::function0<void>::operator()() const (function_template.hpp:763)
9==21957== by 0x2D6647: boost::detail::forward::operator()() (execution_monitor.ipp:1388)
10==21957== by 0x2D627F: boost::detail::function::function_obj_invoker0<boost::detail::forward, int>::invoke(boost::detail::function::function_buffer&) (function_template.hpp:137)
11==21957== by 0x2D0393: boost::function0<int>::operator()() const (function_template.hpp:763)
12==21957== by 0x234A6B: int boost::detail::do_invoke<boost::shared_ptr<boost::detail::translator_holder_base>, boost::function<int ()> >(boost::shared_ptr<boost::detail::translator_holder_base> const&, boost::function<int ()> const&) (execution_monitor.ipp:301)
13==21957== by 0x1F7277: boost::execution_monitor::catch_signals(boost::function<int ()> const&) (execution_monitor.ipp:903)
14==21957==
15{
16 <insert_a_suppression_name_here>
17 Memcheck:Overlap
18 fun:__GI_memcpy
19 fun:_ZN5CTxInaSERKS_
20 fun:_ZL16SignatureHashOld7CScriptRK12CTransactionji
21 fun:_ZN13sighash_tests12sighash_test11test_methodEv
22 fun:_ZN13sighash_testsL20sighash_test_invokerEv
23 fun:_ZN5boost6detail8function22void_function_invoker0IPFvvEvE6invokeERNS1_15function_bufferE
24 fun:_ZNK5boost9function0IvEclEv
25 fun:_ZN5boost6detail7forwardclEv
26 fun:_ZN5boost6detail8function21function_obj_invoker0INS0_7forwardEiE6invokeERNS1_15function_bufferE
27 fun:_ZNK5boost9function0IiEclEv
28 fun:_ZN5boost6detail9do_invokeINS_10shared_ptrINS0_22translator_holder_baseEEENS_8functionIFivEEEEEiRKT_RKT0_
29 fun:_ZN5boost17execution_monitor13catch_signalsERKNS_8functionIFivEEE
30}
vs running this branch:
0real 118m55.057s
Disadvantages includes:
- Becoming slightly more of a package manager in the CI.
Related to the discussion in #27444. See also https://github.com/bitcoin-core/qa-assets/pull/136.