-
Notifications
You must be signed in to change notification settings - Fork 273
Support overflow plus/minus expressions over pointers #6881
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
base: develop
Are you sure you want to change the base?
Conversation
We did not specify that using overflow+/overflow- for pointer +/- integer was unsupported. The translation via regular arithmetic overflow, however, would produce results that did not take into account the peculiarities of pointer arithmetic. Fixing this now also makes it possible to take into account the implementation details of the object/offset encoding, which would result in overflows even when full-width addition/subtraction would not have overflowed. Fixes: diffblue#6842
f580917
to
d70c7c7
Compare
Codecov Report
@@ Coverage Diff @@
## develop #6881 +/- ##
========================================
Coverage 77.79% 77.80%
========================================
Files 1567 1567
Lines 179841 179898 +57
========================================
+ Hits 139913 139969 +56
- Misses 39928 39929 +1
Continue to review full report at Codecov.
|
I do see an issue here considering the semantics of the user-visible check. The C standard is very clear that even just computing a pointer that's "below" the object or more than one past the end is undefined behaviour. As a user, I'd expect that to be checked when told that the tool checks pointer overflow. I suspect that the rationale for this PR is that the limited-width pointer encoding means that we don't -- however, the proposed check is incomparable to the one the user wants. |
I'd say that the proper answer to this problem is to get "full width" pointers, and then to check the pointer range against the object size on any pointer arithmetic expression whenever |
We did not specify that using overflow+/overflow- for pointer +/-
integer was unsupported. The translation via regular arithmetic
overflow, however, would produce results that did not take into account
the peculiarities of pointer arithmetic.
Fixing this now also makes it possible to take into account the
implementation details of the object/offset encoding, which would result
in overflows even when full-width addition/subtraction would not have
overflowed.
Fixes: #6842