[clang] [CodeGen] -fsanitize=alignment: add cl::opt sanitize-alignment-builtin to disable memcpy instrumentation (PR #69240)
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 18 11:25:55 PDT 2023
MaskRay wrote:
> > For reference, can you give a couple examples of code where this is triggering?
> > If this is triggering in practice, do we want a real driver option to control the sanitizer? The alignment attributes themselves?
> I am not sure we need special driver flag for that.
>
> @MaskRay After reading about amount of unique cases you see, maybe ignore list is easier?
Given the scale of our internal code base, the identified unique failures are moderate. So eventually we can remove the `cl::opt` option, but having the option buys us time to clean up the code base.
Many problems identified look like this:
https://chromium.googlesource.com/v8/v8.git/+/bb2ac8991c64601be9852d88c22abac2d6a6c39b/src/bigint/bigint.h#120
```cpp
protected:
friend class ShiftedDigits;
digit_t* digits_; // digits_ may be misaligned
int len_;
private:
// We require externally-provided digits arrays to be 4-byte aligned, but
// not necessarily 8-byte aligned; so on 64-bit platforms we use memcpy
// to allow unaligned reads.
digit_t read_4byte_aligned(int i) {
if (sizeof(digit_t) == 4) {
return digits_[i];
} else {
digit_t result;
memcpy(&result, digits_ + i, sizeof(result)); // unspecified behavior identified here
return result;
}
}
};
```
https://github.com/llvm/llvm-project/pull/69240
More information about the cfe-commits
mailing list