GH-45180: [C++][Fuzzing] Fix Negation bug discovered by fuzzing#45181
GH-45180: [C++][Fuzzing] Fix Negation bug discovered by fuzzing#45181pitrou merged 4 commits intoapache:mainfrom
Conversation
|
|
|
Can you post the original backtrace? IMHO, Decimal32 and Decimal64 are not supposed to hold a number that large in the first place. |
|
@pitrou I agree, they aren't supposed to hold values that large. Which is why this was found during fuzzing rather than regular testing I suppose. The original stacktrace shows that the issue was encountered via the |
|
In this case I think the safety checks deserve to be in |
|
(also should check how Decimal128 and Decimal256 behave in similar cases?) |
|
Are you thinking just a simple |
|
both Decimal128 and Decimal256 use the |
I was thinking that indeed. However, we may also want to make Negate safe if it's safe in Decimal128/256. But this means we might have to move the |
|
@pitrou Current version work for you? |
|
@zeroshade Can you open a PR to add the regression file in https://github.com/apache/arrow-testing/tree/master/data/arrow-ipc-file ? It will then get picked up by the ASAN/UBSAN CI job. |
pitrou
left a comment
There was a problem hiding this comment.
LGTM, but should update the arrow-testing submodule once the regression file is checked in there.
|
Added apache/arrow-testing#104 though I still wasn't able to reproduce the issue with the downloaded clusterfuzz file. I only worked it out by reading through the reported stack trace. |
From this OSS-Fuzz issue: https://issues.oss-fuzz.com/issues/371239168 Fixed with apache/arrow#45181
Unfortunately that can depend on the compiler version and other details. But it's still good to have it somewhere. |
|
Thanks a lot @zeroshade ! @amoeba This is a good candidate for 19.0.0 if not too late. |
|
It's too late for RC0 but I'll mark the issue in case we do an RC1. |
|
After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit b1bb480. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 9 possible false positives for unstable benchmarks that are known to sometimes produce them. |
### Rationale for this change If the value for Decimal32 or Decimal64 is `INT32_MIN` or `INT64_MIN` respectively, then UBSAN reports an issue when calling Negate on them due to overflow. ### What changes are included in this PR? Have the `Negate` methods of Decimal32 and Decimal64 use `arrow::internal::SafeSignedNegate`. ### Are these changes tested? Unit tests were added for both cases which were able to reproduce the problem when UBSAN was on without the fix. ### Are there any user-facing changes? No. * OSS-Fuzz issue: https://issues.oss-fuzz.com/issues/371239168 * GitHub Issue: #45180 Authored-by: Matt Topol <zotthewizard@gmail.com> Signed-off-by: Antoine Pitrou <antoine@python.org>
### Rationale for this change If the value for Decimal32 or Decimal64 is `INT32_MIN` or `INT64_MIN` respectively, then UBSAN reports an issue when calling Negate on them due to overflow. ### What changes are included in this PR? Have the `Negate` methods of Decimal32 and Decimal64 use `arrow::internal::SafeSignedNegate`. ### Are these changes tested? Unit tests were added for both cases which were able to reproduce the problem when UBSAN was on without the fix. ### Are there any user-facing changes? No. * OSS-Fuzz issue: https://issues.oss-fuzz.com/issues/371239168 * GitHub Issue: #45180 Authored-by: Matt Topol <zotthewizard@gmail.com> Signed-off-by: Antoine Pitrou <antoine@python.org>
Rationale for this change
If the value for Decimal32 or Decimal64 is
INT32_MINorINT64_MINrespectively, then UBSAN reports an issue when calling Negate on them due to overflow.What changes are included in this PR?
Have the
Negatemethods of Decimal32 and Decimal64 usearrow::internal::SafeSignedNegate.Are these changes tested?
Unit tests were added for both cases which were able to reproduce the problem when UBSAN was on without the fix.
Are there any user-facing changes?
No.