This is an archive of the discontinued LLVM Phabricator instance.

[test-suite] Fix unaligned uint32_t accesses in ClamAV.
ClosedPublic

Authored by craig.topper on Jun 23 2022, 9:37 PM.

Details

Summary

The char* here isn't 4 byte aligned so the cast to int32_t* can
create an unaligned access.

Replace with a memcpy.

Diff Detail

Repository
rT test-suite

Event Timeline

craig.topper created this revision.Jun 23 2022, 9:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2022, 9:37 PM
Herald added a subscriber: StephenFan. · View Herald Transcript
craig.topper requested review of this revision.Jun 23 2022, 9:37 PM

LGTM, but at the same time, I have no idea whether we're *supposed* to make changes to the source code for these projects or not (my understanding is that they're real world code and so we don't want to change the source code because then it's not reflective of real world code any longer, but I could be totally wrong).

craig.topper added a comment.EditedJun 24 2022, 8:06 AM

LGTM, but at the same time, I have no idea whether we're *supposed* to make changes to the source code for these projects or not (my understanding is that they're real world code and so we don't want to change the source code because then it's not reflective of real world code any longer, but I could be totally wrong).

FWIW the current ClamAV repo uses a packed union to convert to int32 and has for 14 years. https://github.com/Cisco-Talos/clamav/blob/62bf3bea329a13d8416d72d289f72bba3e5a1933/libclamav/others.h

It looks like the copy in llvm-test-suite was created 15 years ago.

luismarques accepted this revision.Jun 24 2022, 3:56 PM
This revision is now accepted and ready to land.Jun 24 2022, 3:56 PM
MaskRay accepted this revision.Jun 26 2022, 5:22 PM

LGTM, since the upstream has fixed it, even in a different way. A misaligned access would manifest as a -fsanitize=alignment failure. llvm test suite can be useful to benchmark sanitizers.