From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9D3AA3858D37; Wed, 20 Jul 2022 10:02:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9D3AA3858D37 From: "shaohua.li at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/106368] New: ASan fails to report an error. Date: Wed, 20 Jul 2022 10:02:24 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: shaohua.li at inf dot ethz.ch X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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 target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2022 10:02:24 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106368 Bug ID: 106368 Summary: ASan fails to report an error. Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: shaohua.li at inf dot ethz.ch 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, marxi= n at gcc dot gnu.org Target Milestone: --- Hi, For the following code snippet, `gcc-trunk -O0 -fsanitize=3Daddress` reports nothing but `gcc-trunk -O3` reports it. $ cat a.c #pragma pack(1) struct a { int b; long c }; #pragma pack() struct d { long b; struct a c }; struct d f; static long *g =3D &f.c.c; int main() { volatile int e =3D *(g+1); } $ $gcc-trunk -O0 -fsanitize=3Daddress a.c && ./a.out $ $gcc-trunk -O3 -fsanitize=3Daddress a.c && ./a.out =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D1=3D=3DERROR: AddressSanitizer: unknown-crash on address 0x0000004041= 34 at pc 0x0000004011a8 bp 0x7ffeadf39d20 sp 0x7ffeadf39d18 READ of size 8 at 0x000000404134 thread T0 #0 0x4011a7 in main /app/example.c:14 #1 0x7f044e5530b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b2) (BuildId: 9fdb74e7b217d06c93172a8243f8547f947ee6d1) #2 0x40120d in _start (/app/output.s+0x40120d) (BuildId: a4a82ec9bae1cc563083aff345004ea80e8df0db) 0x000000404138 is located 0 bytes to the right of global variable 'f' defin= ed in '/app/example.c:11:10' (0x404120) of size 24 SUMMARY: AddressSanitizer: unknown-crash /app/example.c:14 in main Shadow bytes around the buggy address: 0x0000800787d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0000800787e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0000800787f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x000080078800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x000080078810: 00 00 00 00 f9 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 =3D>0x000080078820: 00 00 00 00 00 00[00]f9 f9 f9 f9 f9 00 00 00 00 0x000080078830: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x000080078840: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x000080078850: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x000080078860: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x000080078870: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07=20 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb =3D=3D1=3D=3DABORTING=