refactor: UBSAN build and address out of bound reads #4440
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolved issues:
Relevant to #4438
Description of changes:
This commit adds an
UBSAN
option to our CMake build, which can be enabled with the following.This also addresses some of the out-of-bounds errors that were occuring
These errors were occuring because we were iterating over a two dimensional array with a single index value. This is correct only if you know that the two dimensional array is contiguous in memory, and that it is "row"-major.
Call-outs:
This does not solve all of the UB errors that UBSAN reports.
I suspect that fixing this is going to break some of the cbmc/SAW stuff :(.
Once this is merged in, I plan to add a UBSAN codebuild job to prevent any regressions on this issue.
Testing:
This is currently only run locally. But while we chip away at these, it is useful to have a nice command to do it 😄
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.