From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 10A6D3854557; Thu, 17 Nov 2022 17:36:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 10A6D3854557 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668706577; bh=XQwNrR3+tz20nDvnjw7JCVI5gkBQy8Cn2yGf6NYdvJw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Zq6P2FMDw+t3qTEDUfdkGAjRkZbA04CNcHu6cCJtrsPelB7w72E7xO4T1oVaFKp6f BbnXdjHSwt+i0mJEsqs1RB/AsS91WMJC35vTslumDbvnEdYGn+4Ze1sJqvVSSPD3Dx tweZzqcJ80ecKJMsI/j3KUObmFTaeheQUpEKEfNU= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/107711] [13 Regression] ICE with "-fanalyzer -Wunused-macros" since r13-4073-gd8aba860b34203 Date: Thu, 17 Nov 2022 17:36:06 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: analyzer X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: patch X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: WAITING 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: 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=3D107711 --- Comment #11 from CVS Commits --- The master branch has been updated by David Malcolm : https://gcc.gnu.org/g:f9ed1d24ee46f5ca759c35a1f51fa163d7529ea6 commit r13-4130-gf9ed1d24ee46f5ca759c35a1f51fa163d7529ea6 Author: David Malcolm Date: Thu Nov 17 12:34:56 2022 -0500 c, analyzer: fix ICE with -fanalyzer and -Wunused-macros [PR107711] PR analyzer/107711 reports an ICE since r13-4073-gd8aba860b34203 with the combination of -fanalyzer and -Wunused-macros. The issue is that in c_translation_unit::consider_macro's call to cpp_create_reader I was passing "ident_hash" for use by the the new reader, but that takes ownership of that hash_table, so that ident_hash erroneously gets freed when c_translation_unit::consider_macro calls cpp_destroy, leading to a use-after-free in -Wunused-macros, where: (gdb) p pfile->hash_table->pfile =3D=3D pfile $23 =3D false and it's instead pointing at the freed reader from consider_macro, leading to a use-after-free ICE. Fixed thusly. gcc/c/ChangeLog: PR analyzer/107711 * c-parser.cc (ana::c_translation_unit::consider_macro): Pass N= ULL to cpp_create_reader, rather than ident_hash, so that the new reader gets its own hash table. gcc/testsuite/ChangeLog: PR analyzer/107711 * gcc.dg/analyzer/named-constants-Wunused-macros.c: New test. Signed-off-by: David Malcolm =