From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15268 invoked by alias); 10 Nov 2014 08:28:47 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 14550 invoked by uid 48); 10 Nov 2014 08:28:40 -0000 From: "ryabinin.a.a at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/63802] New: UBSan doesn't catch misaligned access if address is 16-bytes (or more) aligned Date: Mon, 10 Nov 2014 08:28:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: sanitizer X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ryabinin.a.a at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-11/txt/msg00664.txt.bz2 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 ^