From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E7D733858CDB; Wed, 29 Mar 2023 08:18:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E7D733858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680077926; bh=2ZPFtiQxBiZABFN90ABBf6n316WaPBsJBb1kxyhuwbs=; h=From:To:Subject:Date:From; b=ATlu43RYdyEK85PcL+Gzw3ENz0H6R2pMo1j090r88jGQ6u7LtoOrSUb+CsPfhSuol Fqak3Gs7NLhtixJd9+Pu0Iq7AUdViJmsGcTIw5t6VSEb8+OO8N8WMN6YDYji9DjXEu 1msSPxb/F+29YT5bVZoMH6VhqGwV53v6omXepbac= From: "shaohua.li at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/109330] New: ASAN since GCC-9 missed a stack-use-after-scope at -O3 Date: Wed, 29 Mar 2023 08:18:46 +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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109330 Bug ID: 109330 Summary: ASAN since GCC-9 missed a stack-use-after-scope at -O3 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: --- For the following code, ASAN at -O3 since GCC-9 missed the use-after-scope. I checked the code and found that `*f=3D*g` and `return *f` were not optimi= zed away by the compiler. Compiler explorer: https://godbolt.org/z/c96a6jWrY % cat a.c int a, c, d; char b, e; int main() { int *f =3D &a, *g =3D &c; h: &g; for (; 0;) goto h; d =3D 0; for (; d <=3D 3; d++) { int i =3D *f; b && (e =3D 1); f =3D &i; } *f =3D *g; return *f; } % gcc-tk -O3 -fsanitize=3Daddress a.c && ./a.out % % gcc-8 -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: stack-use-after-scope on address 0x7f= fd6b6b94d0 at pc 0x0000004008e1 bp 0x7ffd6b6b94a0 sp 0x7ffd6b6b9498 WRITE of size 4 at 0x7ffd6b6b94d0 thread T0 #0 0x4008e0 in main /a.c:15 ... %=