-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Make all tests pass UBSan without using any UBSan suppressions #17208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
84d6adc
to
5b88e64
Compare
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
…es fixed). Add documentation. 0616138 tests: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. (practicalswift) Pull request description: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. This PR is the CI-only subset of #17208 (which touches code). From a fuzzing perspective it would be really nice to be able to run UBSan with as few suppressions as possible :) Top commit has no ACKs. Tree-SHA512: a926ab3e80e12a805af110fbff470cdc61ef4db536919a5b8896ea8b70f761114a52d9b1c0f48b11c1d48338351bf2e003e01ce60c613612f26ba298dcc29cd9
5b88e64
to
bc993e8
Compare
Primary platforms Bitcoin runs on (x86 / win linux) are not strictly IEEE 754 (in particular, the standard x86 FPU is non-754 due to excess precision and non-strict truncation when moving between registers and memory). It's also not too uncommon for random obscure library code to silently dork around with rounding settings even on SSE (which is much more 754). Standard compiler optimization settings also break IEEE 754 handling even more than the base platform. So I think it's not especially wise to make a very strong assumption of IEEE 754 overall. I don't know if any of that directly impacts this change (though 0/0 is NaN as is 1 / +/-0) Also, there are values other than ==0.0 which in division can produce under/overflow so it's not instantly obvious that the 0.0 equality tests in the code are correct. (in general, equality tests in floating point code are frequent sources of bugs). Inserting extra floating point variables to silence a non-error error seems kinda ugly. Considering that these are just debugging messages, it might be better to just rework them (e.g. don't print if there is nothing to report, or don't divide numbers just give the raw numbers). Returning "inf" in debug lines also might needlessly mess up parsing just as much as not outputting the log in 'impossible' cases where the time elapsed is zero. |
@gmaxwell Thanks for reviewing. Those are all good points. I agree that we should be careful with the IEEE 754 assumptions we're making. I've now pushed an updated version of this PR -- now doing: 1.) -static int64_t nBlocksTotal = 0;
+static int64_t nBlocksTotal = 1; As suggested in a related PR: "This change would have been better done-- easier to review for correctness, more stable against "regression"-- by simply changing the existing initialization constant for nBlocksTotal from 0 to 1." 2.) As suggested: now giving raw numbers instead of percentages. 3.) Setting Please re-review :) Fun bonus trivia
:) |
c4107b2
to
ed3e044
Compare
@MarcoFalke @laanwj @Empact @promag You've all shown interest in the sanitizers before: would you mind reviewing? :) |
ed3e044
to
9724a0c
Compare
Feel free to review the updated version - would be nice to get rid of the UBSan suppressions :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Big concept ACK -- I was about to open a PR about this and then saw this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonatack I'm leaving this one as up for grabs. Feel free to cherry pick in the commits in a new PR: I think this PR has a greater probability of getting merged if you submit it TBH :) |
@practicalswift heh, to the contrary you are more effective than I at having testing improvements merged -- nevertheless, I empathise :) Let's see if #15283 makes headway. |
I was informed that there was some interest expressed in this PR at this week's meeting. Re-opening to give it another chance :) Pinging in @jonatack, @laanwj. @instagibbs and @elichai who I understood sounded positive at the meeting - would you mind reviewing? :) This net change of -8 lines should hopefully be easy to review for correctness :) |
I can't get the sanitizer to complain about these, tried both gcc and clang with commit ab9de43
tried even removing the first 6 lines in |
@elichai try |
@practicalswift thanks for re-opening. I prefer this PR for the reasons I mention in #15283 (comment), so my review above stands. |
Still nothing :/ It does seem to be part of the build: (and I added a out of bound read to one of the tests and it caught it)
|
@elichai I think the reason you're not seeing this when using Clang is that you're using a more recent Clang than the one we're using in Travis: |
Makes sense. but I also can't see it with gcc not just clang
|
Finally.
After:
|
I'll leave this PR open for one week to allow for ACK:s to measure interest :) Will close if no interest shown :) |
Closing due to lack of interest :) |
…s (issues fixed). Add documentation. 0616138 tests: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. (practicalswift) Pull request description: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. This PR is the CI-only subset of bitcoin#17208 (which touches code). From a fuzzing perspective it would be really nice to be able to run UBSan with as few suppressions as possible :) Top commit has no ACKs. Tree-SHA512: a926ab3e80e12a805af110fbff470cdc61ef4db536919a5b8896ea8b70f761114a52d9b1c0f48b11c1d48338351bf2e003e01ce60c613612f26ba298dcc29cd9
…s (issues fixed). Add documentation. 0616138 tests: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. (practicalswift) Pull request description: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. This PR is the CI-only subset of bitcoin#17208 (which touches code). From a fuzzing perspective it would be really nice to be able to run UBSan with as few suppressions as possible :) Top commit has no ACKs. Tree-SHA512: a926ab3e80e12a805af110fbff470cdc61ef4db536919a5b8896ea8b70f761114a52d9b1c0f48b11c1d48338351bf2e003e01ce60c613612f26ba298dcc29cd9
…s (issues fixed). Add documentation. 0616138 tests: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. (practicalswift) Pull request description: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. This PR is the CI-only subset of bitcoin#17208 (which touches code). From a fuzzing perspective it would be really nice to be able to run UBSan with as few suppressions as possible :) Top commit has no ACKs. Tree-SHA512: a926ab3e80e12a805af110fbff470cdc61ef4db536919a5b8896ea8b70f761114a52d9b1c0f48b11c1d48338351bf2e003e01ce60c613612f26ba298dcc29cd9
…s (issues fixed). Add documentation. 0616138 tests: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. (practicalswift) Pull request description: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. This PR is the CI-only subset of bitcoin#17208 (which touches code). From a fuzzing perspective it would be really nice to be able to run UBSan with as few suppressions as possible :) Top commit has no ACKs. Tree-SHA512: a926ab3e80e12a805af110fbff470cdc61ef4db536919a5b8896ea8b70f761114a52d9b1c0f48b11c1d48338351bf2e003e01ce60c613612f26ba298dcc29cd9
…s (issues fixed). Add documentation. 0616138 tests: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. (practicalswift) Pull request description: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. This PR is the CI-only subset of bitcoin#17208 (which touches code). From a fuzzing perspective it would be really nice to be able to run UBSan with as few suppressions as possible :) Top commit has no ACKs. Tree-SHA512: a926ab3e80e12a805af110fbff470cdc61ef4db536919a5b8896ea8b70f761114a52d9b1c0f48b11c1d48338351bf2e003e01ce60c613612f26ba298dcc29cd9
…s (issues fixed). Add documentation. 0616138 tests: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. (practicalswift) Pull request description: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. This PR is the CI-only subset of bitcoin#17208 (which touches code). From a fuzzing perspective it would be really nice to be able to run UBSan with as few suppressions as possible :) Top commit has no ACKs. Tree-SHA512: a926ab3e80e12a805af110fbff470cdc61ef4db536919a5b8896ea8b70f761114a52d9b1c0f48b11c1d48338351bf2e003e01ce60c613612f26ba298dcc29cd9
…s (issues fixed). Add documentation. 0616138 tests: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. (practicalswift) Pull request description: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. This PR is the CI-only subset of bitcoin#17208 (which touches code). From a fuzzing perspective it would be really nice to be able to run UBSan with as few suppressions as possible :) Top commit has no ACKs. Tree-SHA512: a926ab3e80e12a805af110fbff470cdc61ef4db536919a5b8896ea8b70f761114a52d9b1c0f48b11c1d48338351bf2e003e01ce60c613612f26ba298dcc29cd9
…s (issues fixed). Add documentation. 0616138 tests: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. (practicalswift) Pull request description: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. This PR is the CI-only subset of bitcoin#17208 (which touches code). From a fuzzing perspective it would be really nice to be able to run UBSan with as few suppressions as possible :) Top commit has no ACKs. Tree-SHA512: a926ab3e80e12a805af110fbff470cdc61ef4db536919a5b8896ea8b70f761114a52d9b1c0f48b11c1d48338351bf2e003e01ce60c613612f26ba298dcc29cd9
…s (issues fixed). Add documentation. 0616138 tests: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. (practicalswift) Pull request description: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. This PR is the CI-only subset of bitcoin#17208 (which touches code). From a fuzzing perspective it would be really nice to be able to run UBSan with as few suppressions as possible :) Top commit has no ACKs. Tree-SHA512: a926ab3e80e12a805af110fbff470cdc61ef4db536919a5b8896ea8b70f761114a52d9b1c0f48b11c1d48338351bf2e003e01ce60c613612f26ba298dcc29cd9
…s (issues fixed). Add documentation. 0616138 tests: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. (practicalswift) Pull request description: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. This PR is the CI-only subset of bitcoin#17208 (which touches code). From a fuzzing perspective it would be really nice to be able to run UBSan with as few suppressions as possible :) Top commit has no ACKs. Tree-SHA512: a926ab3e80e12a805af110fbff470cdc61ef4db536919a5b8896ea8b70f761114a52d9b1c0f48b11c1d48338351bf2e003e01ce60c613612f26ba298dcc29cd9
…s (issues fixed). Add documentation. 0616138 tests: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. (practicalswift) Pull request description: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. This PR is the CI-only subset of bitcoin#17208 (which touches code). From a fuzzing perspective it would be really nice to be able to run UBSan with as few suppressions as possible :) Top commit has no ACKs. Tree-SHA512: a926ab3e80e12a805af110fbff470cdc61ef4db536919a5b8896ea8b70f761114a52d9b1c0f48b11c1d48338351bf2e003e01ce60c613612f26ba298dcc29cd9
Make all tests pass UBSan (
-fsanitize=undefined
) without using any UBSan suppressions.From a fuzzing perspective it would be really nice to be able to run UBSan without having to deal with suppression files :)
Note that the commit c8c393b needs to be cherry-picked in from PR #17156 to get rid of the two alignment related suppressions :)
Before this PR:
After this PR (with cherry-pick as described above):
Note: This PR is not a bug fix (there is no bug to fix!). We assume the floating-point types to fulfil the requirements of IEC 559 (IEEE 754) standard: floating-point division by zero is thus well-defined.
The IEC 559 (IEEE 754) assumption is made explicitly in
assumptions.h
and also checked at compile-time:bitcoin/src/compat/assumptions.h
Lines 31 to 36 in a22b624
However, UBSan is not aware of that assumption we're making.