Add build flag to enable the Undefined Behavior Sanitizer by bjosv · Pull Request #3645 · aws/aws-sdk-cpp
The flag can be enabled in CMake using -DENABLE_UB_SANITIZER=ON similar to the existing flag for the address sanitizer.
Building aws-sdk-cpp (and its dependencies) with this flag indicates a couple of issues, like:
aws-sdk-cpp/src/aws-cpp-sdk-core/include/aws/core/client/AWSClientAsyncCRTP.h:51:40: runtime error: downcast of address 0x7ffe7bff5b90 which does not point to an object of type 'Aws::S3::S3Client'
aws-sdk-cpp/src/aws-cpp-sdk-core/include/aws/core/utils/stream/StreamBufProtectedWriter.h:46:67: runtime error: downcast of address 0x7ffd80fa21e8 which does not point to an object of type 'StreamBufProtectedWriter'
aws-sdk-cpp/crt/aws-crt-cpp/crt/aws-c-common/source/hash_table.c:68:12: runtime error: call to function aws_byte_cursor_eq through pointer to incorrect function type 'bool (*)(const void *, const void *)'
aws-sdk-cpp/crt/aws-crt-cpp/crt/aws-c-sdkutils/source/endpoints_util.c:50:24: runtime error: addition of unsigned offset to 0x595033296ca0 overflowed to 0x595033296c9f
aws-sdk-cpp/tests/aws-cpp-sdk-core-tests/utils/crypto/SymmetricCiphersTest.cpp:689:12: runtime error: null pointer passed as argument 1, which is declared to never be null
aws-sdk-cpp/tests/aws-cpp-sdk-core-tests/utils/crypto/SymmetricCiphersTest.cpp:689:43: runtime error: null pointer passed as argument 2, which is declared to never be null
Existing PRs to fix above issues are: awslabs/aws-c-http#531 and awslabs/aws-c-sdkutils#58
Related issue for one issue: #3464
Some of these issues are also seen when a SDK-user builds with UBSan.
Maybe we should add a CI-step building with this flag?
Check all that applies:
- Did a review by yourself.
- Added proper tests to cover this PR. (Can be added to CI?)
- Checked if this PR is a breaking (APIs have been changed) change.
- Checked if this PR will not introduce cross-platform inconsistent behavior.
- Checked if this PR would require a ReadMe/Wiki update.
Check which platforms you have built SDK on to verify the correctness of this PR.
- Linux
- Windows
- Android
- MacOS
- IOS
- Other Platforms
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.