-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
[Sanitizer] add signed-integer-wrap sanitizer #80089
Changes from all commits
7774e40
7c959a1
77732cb
d9d7737
f00e6a3
01699c1
5497e8b
e964431
e15b6e6
b978be6
a9c4ef3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,7 +193,14 @@ Available checks are: | |
signed division overflow (``INT_MIN/-1``), but not checks for | ||
lossy implicit conversions performed before the computation | ||
(see ``-fsanitize=implicit-conversion``). Both of these two issues are | ||
handled by ``-fsanitize=implicit-conversion`` group of checks. | ||
handled by ``-fsanitize=implicit-conversion`` group of checks. Note that | ||
``-fwrapv`` implicitly disables instrumentation for much of the arithmetic | ||
covered by ``-fsanitize=signed-integer-overflow``. | ||
- ``-fsanitize=signed-integer-wrap``: Signed Integer wraparound, where the | ||
result of a signed integer computation wraps around. Behaves identically | ||
to ``-fsanitize=signed-integer-overflow`` when ``-fwrapv`` is enabled. | ||
Without ``-fwrapv`` or ``-fno-strict-overflow``, this sanitizer will only | ||
instrument division operations. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? division looks like overflow to me? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually it's very inconsistent that the sanitizer is less strict without There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was going off the spec:
From H.2.2 Integer Types I initially read this as meaning we need to instrument division no matter what (just in case it's divide by zero or similar case). What is your interpretation? I can add a check for the signed overflow behavior for the division steps -- if needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, this proposed "wrap" sanitizer is less strict when nothing is defined as wrapping (i.e: missing In the same way, |
||
- ``-fsanitize=unreachable``: If control flow reaches an unreachable | ||
program point. | ||
- ``-fsanitize=unsigned-integer-overflow``: Unsigned integer overflow, where | ||
|
@@ -233,8 +240,9 @@ You can also use the following check groups: | |
Enables ``signed-integer-overflow``, ``unsigned-integer-overflow``, | ||
``shift``, ``integer-divide-by-zero``, | ||
``implicit-unsigned-integer-truncation``, | ||
``implicit-signed-integer-truncation``, and | ||
``implicit-integer-sign-change``. | ||
``implicit-signed-integer-truncation``, | ||
``implicit-integer-sign-change``, and | ||
``signed-integer-wrap``. | ||
- ``-fsanitize=nullability``: Enables ``nullability-arg``, | ||
``nullability-assign``, and ``nullability-return``. While violating | ||
nullability does not have undefined behavior, it is often unintentional, | ||
|
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.
Can we refrase this differently?
Instead (or in addition) of reference to
signed-integer-overflow
, just explain that it will detect?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 agree that the current version is not so clear. I must admit, though, I am not 100% sure what changes you would like. Vitaly, do you think it should be worded like such:
If this doesn't match what you were thinking could you let me know?