https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63802

            Bug ID: 63802
           Summary: UBSan doesn't catch misaligned access if address is
                    16-bytes (or more) aligned
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ryabinin.a.a at gmail dot com
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org,
                    mpolacek at gcc dot gnu.org

Created attachment 33929
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33929&action=edit
Repro case

Let's say we have struct that requires 64-bytes alignment.

struct test_struct {
  unsigned long a;
  int b;
} __attribute__((__aligned__(64)));


UBSan will not catch misaligned access if address of such struct is 16 bytes
aligned.

If address is not aligned to 16 bytes, UBSan will catch it, but alignment in
report is wrong (16 instead of 64):

misaligned_test.c:14:80: runtime error: member access within misaligned address
0x0000006011cf for type 'struct test_struct', which requires 16 byte alignment
0x0000006011cf: note: pointer points here
 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
00 00 00 00  00 00 00
             ^

Reply via email to