From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AC22A3857C6F; Tue, 3 Nov 2020 04:11:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC22A3857C6F From: "egallager at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/80532] warning on pointer access after free Date: Tue, 03 Nov 2020 04:11:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 7.0 X-Bugzilla-Keywords: diagnostic, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: egallager at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: dmalcolm at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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 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: Tue, 03 Nov 2020 04:11:16 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D80532 Eric Gallager changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |egallager at gcc dot gnu.o= rg --- Comment #4 from Eric Gallager --- (In reply to David Malcolm from comment #3) > My analyzer finds these: >=20 > ./xgcc -B. -fanalyzer -c ../../src/gcc/testsuite/gcc.dg/analyzer/pr80532.c > -ftime-report > ../../src/gcc/testsuite/gcc.dg/analyzer/pr80532.c: In function =E2=80=98f= ree_list=E2=80=99: > ../../src/gcc/testsuite/gcc.dg/analyzer/pr80532.c:14:28: warning: use aft= er > =E2=80=98free=E2=80=99 of =E2=80=98p=E2=80=99 [CWE-416] [-Wanalyzer-use-a= fter-free] > 14 | for (p =3D head; p !=3D 0; p =3D p->next) /* { dg-warning "use = after > 'free' of 'p'" } */ > | ~~^~~~~~~~~ > =E2=80=98free_list=E2=80=99: events 1-4 > | > | 14 | for (p =3D head; p !=3D 0; p =3D p->next) /* { dg-warning = "use > after 'free' of 'p'" } */ > | | ^~~ ~~~~~~~~~~~ > | | | | > | | | (4) use after =E2=80=98free=E2=80= =99 of =E2=80=98p=E2=80=99; freed > at (3) > | | (1) following =E2=80=98true=E2=80=99 branch (when =E2=80= =98p=E2=80=99 is non-NULL)... > | 15 | free (p); /* { dg-message "freed here" } */ > | | ~~~~~~~~ > | | | > | | (2) ...to here > | | (3) freed here > | > ../../src/gcc/testsuite/gcc.dg/analyzer/pr80532.c:14:28: note: 8 duplicat= es > 14 | for (p =3D head; p !=3D 0; p =3D p->next) /* { dg-warning "use = after > 'free' of 'p'" } */ > | ~~^~~~~~~~~ > ../../src/gcc/testsuite/gcc.dg/analyzer/pr80532.c: In function =E2=80=98f= oobar=E2=80=99: > ../../src/gcc/testsuite/gcc.dg/analyzer/pr80532.c:24:3: warning: > double-=E2=80=98free=E2=80=99 of =E2=80=98p=E2=80=99 [CWE-415] [-Wanalyze= r-double-free] > 24 | free (p); /* { dg-warning "double-'free' of 'p'" } */ > | ^~~~~~~~ > =E2=80=98foobar=E2=80=99: events 1-2 > | > | 22 | memset (p, 0, n); > | | ^~~~~~~~~~~~~~~~ > | | | > | | (1) first =E2=80=98free=E2=80=99 here > | 23 | free (p); /* { dg-message "first 'free' here" } */ > | 24 | free (p); /* { dg-warning "double-'free' of 'p'" } */ > | | ~~~~~~~~ > | | | > | | (2) second =E2=80=98free=E2=80=99 here; first =E2=80=98fre= e=E2=80=99 was at (1) > | So... since the analyzer has been merged now... ok to close as FIXED?=