-
Notifications
You must be signed in to change notification settings - Fork 274
Pointer overflow checks should detect overflow in offset multiplication #6633
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
Pointer overflow checks should detect overflow in offset multiplication #6633
Conversation
5980b0e
to
81276c2
Compare
5204303
to
2a0230e
Compare
Codecov Report
@@ Coverage Diff @@
## develop #6633 +/- ##
========================================
Coverage 76.72% 76.72%
========================================
Files 1579 1579
Lines 181938 181953 +15
========================================
+ Hits 139587 139602 +15
Misses 42351 42351
Continue to review full report at Codecov.
|
35d46f3
to
6d9219d
Compare
src/analyses/goto_check_c.cpp
Outdated
/// | ||
/// A flag's initial value (before any `set_flag` or `disable_flag`) is restored | ||
/// when the entire object goes out of scope. | ||
class flag_resett |
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.
I realise this is just code you've moved, but just wondering about the naming of this class (sorry...) Conceptually what this class is really about is less about "resetting" a flag, and more about introducing a "scope" for the flag? So maybe call it something like flag_scopet
? or flag_overridet
? One for a later PR though.
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.
Good call, I think flag_overridet
is the best match for what it does. I've inserted a commit to do the renaming.
No changes in behaviour, just code motion. Upcoming commits will use this class in `check_rec`.
There isn't any use of fields other than the instruction's source location, so take just that. Also use `as_string()` instead of `pretty()` for more nicely formatted error reporting.
This class no longer is confined to resetting flags, but now has additional override capabilities. Co-authored-by: Chris Ryder <[email protected]>
Pointer arithmetic requires multiplication of the offset by the size of the base type (for any base type larger than 1 byte). Such a multiplication isn't introduced until the back-end, where no opportunity for adding properties exists anymore. Therefore, synthesize the multiplication to generate arithmetic overflow checks at the GOTO level. Fixes: diffblue#6631
6d9219d
to
419837e
Compare
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.
Re-asserting my approval after the extra rename commit, thanks :-)
Pointer arithmetic requires multiplication of the offset by the size of
the base type (for any base type larger than 1 byte). Such a
multiplication isn't introduced until the back-end, where no opportunity
for adding properties exists anymore. Therefore, synthesize the
multiplication to generate arithmetic overflow checks at the GOTO level.
Fixes: #6631