-
Notifications
You must be signed in to change notification settings - Fork 37.8k
Fix integer sanitizer suppressions in validation.cpp #24196
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
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
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.
int
is only guaranteed to have a max value of 32768. In a 2 MB block, that's 61 bytes per input. Seems quite possible to hit it?
OTOH, I don't think we support/work on such platforms right now, so this probably isn't a real issue. So utACK anyway.
It wouldn't be possible to start Bitcoin Core if int max was 32768. See also:
|
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.
utACK fa2d0c7 modulo nit
Changed to a pure refactor, that doesn't change any types. Also, it doesn't change the binary with clang++ -O2 on my system, though with gcc it does. It is the same refactor that was used in ##24227 |
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.
ACK fac6205, I have reviewed the code and it looks OK, I agree it can be merged.
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.
Code Review ACK fac6205
Summary: While looking at backporting [[bitcoin/bitcoin#24196 | core#24196]], I noticed that the offending code was already changed in D359 (`unsigned int` -> `size_t`) and fixed in D1528 (removal of the `for (size_t j = tx.vin.size(); j-- > 0;)` loop) Removing the file-wide suppression means that new UB can now be detected. Test Plan: With UBSAN `ninja && ninja check check-functional` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D12821
It doesn't seem ideal to have an integer sanitizer enabled, but then disable it for the whole validation.cpp file.
Fix it with a refactor and remove the suppression.