ArcticDB
ArcticDB copied to clipboard
Use EncodedFieldImpl.blocks() rather than casting member variable _blocks
Reference Issues/PRs
Fixes part of #1724.
What does this implement or fix?
This fixes one of the undefined behaviours that came to light in issue #1724 when building and testing ArcticDB on macOS ARM using a hardened build of libcxx. The C++ test it fixes is SegmentHeader.SerializeUnserializeV1.
Any other comments?
Previously EncodedFieldImpl::shapes was applying an offset into the _blocks member variable std::array before casting to an EncodedBlock. Other use of _blocks in this class uses the member function blocks() to do it the other way round, i.e. casting then offsetting. In practice this has been fine but in principle it is not as some hardware platform could have some interesting memory alignment to mess this up, which is what the hardened libcxx identifies.
The fix is to use the same approach in shapes() to that in values(), the function below it.
I have tested this locally against a hardened build on macOS ARM, and also against an unhardened build on Ubuntu. Hardened builds are currently not tested in CI and I suspect that we don't want to add one as it would be considered a poor use of CI resources.