This is an archive of the discontinued LLVM Phabricator instance.

Fix __attribute__((force_align_arg_pointer)) misalignment bug
ClosedPublic

Authored by Gramner on Apr 19 2018, 6:05 AM.

Details

Summary

The force_align_arg_pointer attribute was using a hardcoded 16-byte
alignment value which in combination with -mstack-alignment=32 (or
larger) would produce a misaligned stack which could result in crashes
when accessing stack buffers using aligned AVX load/store instructions.

Fix the issue by using the "stackrealign" function attribute instead
of using a hardcoded 16-byte alignment.

Diff Detail

Repository
rC Clang

Event Timeline

Gramner created this revision.Apr 19 2018, 6:05 AM

Can you make sure that this doesn't cause stackrealign to happen 2x if using -mstackrealign? Additionally, please provide the diff with full-context (see https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface). What is the commit before this? The line numbers don't look right to me.

Barring any surprises from those two, this looks alright to me.

Gramner updated this revision to Diff 143083.Apr 19 2018, 6:30 AM

Full context.

Can you make sure that this doesn't cause stackrealign to happen 2x if using -mstackrealign? Additionally, please provide the diff with full-context (see https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface). What is the commit before this? The line numbers don't look right to me.

Barring any surprises from those two, this looks alright to me.

The commit before this one is git hash 4889058f23607ff086470afe013082ca4a278ddb

It does "the right thing" as far as I can see, e.g. no double stack realignment or anything weird, when tested on 64-bit Linux with various combinations (and lack of thereof) of -mstack-alignment=32, -mstack-alignment=64, -mstackrealign, -m32. Unable to test on other systems though.

erichkeane accepted this revision.Apr 19 2018, 7:21 AM

LGTM, Do you have commit access, or do you want me to commit it for you?

This revision is now accepted and ready to land.Apr 19 2018, 7:21 AM

LGTM, Do you have commit access, or do you want me to commit it for you?

I do not have commit access, so please do. Thanks for the review.

This revision was automatically updated to reflect the committed changes.