Skip to content

Conversation

practicalswift
Copy link
Contributor

@practicalswift practicalswift commented Nov 30, 2019

Add make check-valgrind to run the unit tests under Valgrind.

Fix uninitialized read in CWallet::CreateTransaction(...) which is required for make valgrind-check to pass. Update: Fixed by the merge of #17568.

Reviewers of this PR might be interested in the related PR #17633 ("tests: Add option --valgrind to run the functional tests under Valgrind").

Hopefully this will help kill the uninitialized read bug class :)

@fanquake fanquake added the Tests label Nov 30, 2019
@fanquake
Copy link
Member

Instead of 8c6edc2, you can cherry-pick from #17568, which already fixes the uninitialized read issue and adds a test.

@practicalswift
Copy link
Contributor Author

@fanquake Done! :)

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 30, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

No conflicts as of last run.

@practicalswift practicalswift changed the title tests: Add "make check-valgrind" to run the unit tests under Valgrind. Fix uninitialized read in CWallet::CreateTransaction(...). tests: Add "make check-valgrind" to run the unit tests under Valgrind Dec 1, 2019
Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK - Unfortunately Valgrind support on macOS is somewhat limited (even building the master branch).

@fjahr
Copy link
Contributor

fjahr commented Dec 17, 2019

Concept ACK

Also unfortunately not able to test because of valgrind/macOS shenanigans at the moment.

@jonatack
Copy link
Member

Would someone please add a Review Club label to this PR? Thanks :)

@practicalswift
Copy link
Contributor Author

practicalswift commented Dec 17, 2019

Welcome all review club members! Unfortunately I cannot attend your meeting today but you should know that I'm a huge fan of what you are doing: by reviewing you're helping to make Bitcoin Core harder, better, faster and stronger! :)

Looking forward to reading your reviews/feedback!

Remember: given enough eyeballs all bugs are shallow :)

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK 947a918. Running make check-valgrind (with valgrind 3.14 on debian) outputs the following. After 15 minutes I see nothing further, so if the tests are running as expected, I'm not sure who will have the patience to run them. Perhaps I'm missing a configuration?

bitcoin ((HEAD detached at origin/pr/17639))$ make check-valgrind
make -C src/ check-valgrind
make[1]: Entering directory '/home/jon/projects/bitcoin/bitcoin/src'
make[2]: Entering directory '/home/jon/projects/bitcoin/bitcoin'
make[2]: Leaving directory '/home/jon/projects/bitcoin/bitcoin'
Using the valgrind memory error detector: expect an ~50x slowdown, valgrind 3.14 or later required
Running test/test_bitcoin under valgrind -- this will take a quite a while ...
valgrind --suppressions=../contrib/valgrind.supp --gen-suppressions=all --exit-on-first-error=yes --error-exitcode=1 --quiet test/test_bitcoin
Running 387 test cases...

EDIT: I debugged this extensively by running valgrind --gen-suppressions=all --verbose --exit-on-first-error=yes --error-exitcode=1 --suppressions=contrib/valgrind.supp src/test/test_bitcoin --log_level=test_suite. The issue for me was that the suppressions file needed additions to make it through the unit tests.

@practicalswift
Copy link
Contributor Author

@jonatack Thanks for reviewing. Would you mind re-reviewing the updated version? :)

@practicalswift
Copy link
Contributor Author

Rebased! :)

@bitcoin bitcoin deleted a comment from Binh0103 Jan 19, 2020
Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 2a57a15 mod comment

@practicalswift
Copy link
Contributor Author

@jonatack No longer using --quiet as requested. Would you mind re-reviewing? :)

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 8942642 mod indentation nit (sorry for the iterative reviewing :)

I've never been able to get fully through any of the suites with valgrind yet because of missing suppressions (and may propose adding some). Therefore, to test this PR I needed to remove L629-631 (the unit tests) to see the bench tests, and then L632-635 (the bench tests) to see the qt tests. This is how I tested.

Edit: progress! valgrinded all the way through the bench and qt suites :)

@practicalswift
Copy link
Contributor Author

Updated. Removed usage of --exit-on-first-error and thus the requirement of a very recent valgrind version.

After thinking about it I came to the conclusion that it is better to optimise for maximum number of valgrind testers than optimising for the rare case that a memory error is found.

Please re-review :)

jonatack added a commit to jonatack/bitcoin that referenced this pull request Feb 19, 2020
This isn't a list of all generated suppressions; I worked to reduce the list to
the minimal number of suppressions necessary so that running valgrind with
--exit-on-first-error can pass.

All tested with valgrind 3.16.0 on Debian 4.19 x86/64.

These suppressions enable running valgrind on current master for the

unit tests

  valgrind --leak-check=full --show-leak-kinds=all --show-reachable=yes \
           --gen-suppressions=all --error-limit=no -s \
           --suppressions=contrib/valgrind.supp \
           src/test/test_bitcoin --log_level=test_suite

bench

  valgrind --leak-check=full --show-leak-kinds=all --show-reachable=yes \
           --gen-suppressions=all --error-limit=no -s \
           --suppressions=contrib/valgrind.supp \
           src/bench/bench_bitcoin -evals=1

qt tests

  valgrind --leak-check=full --show-leak-kinds=all --show-reachable=yes \
           --gen-suppressions=all --error-limit=no -s \
           --suppressions=contrib/valgrind.supp \
           src/qt/test/test_bitcoin-qt --log_level=test_suite

as well as with `make check-valgrind` in PR bitcoin#17639
@jonatack
Copy link
Member

ACK 61fdd79 -- see https://gist.github.com/jonatack/1c0e0b9324ee4cc6c6bd6044c0b1c366 for output of running make check-valgrind.

Thanks to the updated valgrind suppressions in PR #18178 (review welcome), this PR now runs for me with no errors related to our dependencies.

@practicalswift
Copy link
Contributor Author

Any chance we can move forward with this PR?

I'll leave it open for a while to allow for ACK:s and close if no interest is shown :)

@practicalswift
Copy link
Contributor Author

Closing due to lack of interest :)

@practicalswift practicalswift deleted the make-check-valgrind branch April 10, 2021 19:39
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants