From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C7B2E3857818; Mon, 29 Nov 2021 15:25:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C7B2E3857818 From: "jamborm at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/103449] [12 Regression] use-after-free in ipa_param_body_adjustments::prepare_debug_expressions(tree_node*) (ipa-param-manipulation.c:1283) since r12-4920-g1ece90ffa9ce63b4 Date: Mon, 29 Nov 2021 15:25:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jamborm at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 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 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: Mon, 29 Nov 2021 15:25:48 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103449 --- Comment #2 from Martin Jambor --- The second "Invalid read of size 8" can be avoided with the following (untested but correct): diff --git a/gcc/ipa-param-manipulation.c b/gcc/ipa-param-manipulation.c index 479c20b3871..ff65dad0971 100644 --- a/gcc/ipa-param-manipulation.c +++ b/gcc/ipa-param-manipulation.c @@ -1280,8 +1280,9 @@ ipa_param_body_adjustments::prepare_debug_expressions (tree dead_ssa) && TREE_CODE (gimple_assign_rhs1 (def)) =3D=3D SSA_NAME) { tree *d =3D m_dead_ssa_debug_equiv.get (gimple_assign_rhs1 (def)); + gcc_assert (*d); m_dead_ssa_debug_equiv.put (dead_ssa, *d); - return (*d !=3D NULL_TREE); + return true; } tree val But the first one, at least at this point, is somewhat a mystery to me. It happens within the m_dead_ssa_debug_equiv.put() just before the return... and, if I understand the valgrind output well, it seems that inside that hash_map its m_table.find_slot_with_hash returned a pointer to a memory the same m_table released before?=