From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30227 invoked by alias); 20 Feb 2014 08:07:58 -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 30210 invoked by uid 48); 20 Feb 2014 08:07:55 -0000 From: "manjian2006 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/60281] New: Address Sanitizer triggers alignment fault in ARM machines Date: Thu, 20 Feb 2014 08:07:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: manjian2006 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 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-02/txt/msg02057.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60281 Bug ID: 60281 Summary: Address Sanitizer triggers alignment fault in ARM machines Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: manjian2006 at gmail dot com Without aligning the asan stack base,this base will only 64-bit aligned in ARM machines. But asan require 256-bit aligned base because of this: 1.right shift take ASAN_SHADOW_SHIFT ,which is 3,bits are zeros 2.store multiple/load multiple instructions require the other 2 bits are zeros that add up lowest 5 bits should be zeros.That means 32 bytes or 256 bits aligned. Here is the test case: #include int foo() { struct timespec timeNow1 ; clock_gettime( 0, &timeNow1); return static_cast(timeNow1.tv_sec); } compiles command: arm-linux-androideabi-g++ -march=armv7-a -mthumb -Os -fsanitize=address -S 1.cpp which generates assembly as: push {r4, r5, r6, r7, lr} @ save 5*4 = 20 bytes sub sp, sp, #100 @ save 20 + 100 = 120 bytes ... mov r4, sp ... lsrs r5, r4, #3 @ as -120 is 11111111111111111111111110001000 r5 is aligned to 1 bits ... stmia r5, {r1, r2, r3} @ trigger alignment fault