From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DF6E43834872; Wed, 14 Dec 2022 08:26:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DF6E43834872 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671006414; bh=lbhtCAw3nfqdwAXMFfRKFGmPqbQAMqolpCNT8Li08ds=; h=From:To:Subject:Date:In-Reply-To:References:From; b=vqnz/8n9192EeIsCMoxSkH+DXhli9xx3zC0nR3y6ynpiJ7iGMfdgHE1/HcarM1Zoa ZOJQuh3LqbbPlwgTxkWYa+CMpCFizZ3ejji17KY5pd0GuS+fODL+fX1doQfzqNw/2U QJ3PhSPRl1d/i6rHIORfE2gOAXwNoo5cuN8Bvyok= From: "marxin at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/108085] gcc trunk's ASAN at -O3 missed a stack-use-after-scope Date: Wed, 14 Dec 2022 08:26:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed 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: marxin at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: marxin at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: assigned_to cf_reconfirmed_on bug_status everconfirmed Message-ID: In-Reply-To: References: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108085 Martin Li=C5=A1ka changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |marxin at gcc dot g= nu.org Last reconfirmed| |2022-12-14 Status|UNCONFIRMED |ASSIGNED Ever confirmed|0 |1 --- Comment #1 from Martin Li=C5=A1ka --- I can take a look. Note I can't reproduce it with Clang with any of -O1+ options: $ clang pr108085.c -fsanitize=3Daddress -w && ./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 =3D=3D20150=3D=3DERROR: AddressSanitizer: stack-use-after-scope on address 0x7ffff5e00030 at pc 0x55555566a2aa bp 0x7fffffffd510 sp 0x7fffffffd508 READ of size 4 at 0x7ffff5e00030 thread T0 #0 0x55555566a2a9 in main pr108085.c #1 0x7ffff7ca35af in __libc_start_call_main (/lib64/libc.so.6+0x275af) (BuildId: 3f7f40d4302fa8a9568a057065c023bf137fceb7) #2 0x7ffff7ca3678 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x27678) (BuildId: 3f7f40d4302fa8a9568a057065c023bf137fce= b7) #3 0x5555555a9d64 in _start /home/abuild/rpmbuild/BUILD/glibc-2.36/csu/../sysdeps/x86_64/start.S:115 Address 0x7ffff5e00030 is located in stack of thread T0 at offset 48 in fra= me #0 0x55555566a11f in main pr108085.c This frame has 2 object(s): [32, 36) 'd' [48, 52) 'f' <=3D=3D Memory access at offset 48 is inside this variable HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork (longjmp and C++ exceptions *are* supported) SUMMARY: AddressSanitizer: stack-use-after-scope pr108085.c in main Shadow bytes around the buggy address: 0x10007ebb7fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10007ebb7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10007ebb7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10007ebb7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10007ebb7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =3D>0x10007ebb8000: f1 f1 f1 f1 04 f2[f8]f3 00 00 00 00 00 00 00 00 0x10007ebb8010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10007ebb8020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10007ebb8030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10007ebb8040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10007ebb8050: 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=3D20150=3D=3DABORTING $ clang pr108085.c -fsanitize=3Daddress -w -O1 && ./a.out (no output)=