From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3CE583858C66; Wed, 22 Feb 2023 17:18:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3CE583858C66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677086333; bh=e8ENsyRBl1D8R02JEnjsFxlhPskMNNTHij+RnHjQ7K4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=QQdkl9vrldtf37KtV0j0eo7OErk3gLWzMxecLUy5IgkK9DyustufYx0zjGOuHGJLS v7EcpnXuUop1mRkCx5RRlaozgZD/4dA1Ju3GqHEm20u+tohWomImt4GRWgYm3k7+vM GlmH/ZpF6anzw+9GLBA0nP22ObyMB97hoPiRwVbc= From: "mark at klomp dot org" To: elfutils-devel@sourceware.org Subject: [Bug libdw/29434] Memory leak in `dwarf_getscopes` Date: Wed, 22 Feb 2023 17:18:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: elfutils X-Bugzilla-Component: libdw X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mark at klomp dot org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: mark at klomp dot 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://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29434 --- Comment #17 from Mark Wielaard --- So the code here changed a little with this patch: commit b7c7d8776ed46e2237d18fb15c6b72e83cfa259b Author: Mark Wielaard Date: Sun Jan 22 00:31:57 2023 +0100 libdw: Search for abstract origin in the correct CU With gcc -flto the abstract origin of an inlined subroutine could be in a different CU. dwarf_getscopes might return an empty scope if it cannot find the abstract origin scope. So make sure to search in the We also tried to add the origin match in pc_record directly in the current inlined scope. This always failed, causing to do a needless traversal, followed by the full CU scan in dwarf_getscopes. Just always stop the pc_record search and then do the CU origin_match in dwarf_getscopes. Signed-off-by: Mark Wielaard Which makes the condition of the first check slightly different: - if (result =3D=3D 0 && a.scopes !=3D NULL) - result =3D __libdw_visit_scopes (0, &cu, NULL, &origin_match, NULL, &a= ); + if (result >=3D 0 && a.scopes !=3D NULL && a.inlined > 0) + { + /* We like the find the inline function's abstract definition + scope, but that might be in a different CU. */ + cu.die =3D CUDIE (a.inlined_origin.cu); + result =3D __libdw_visit_scopes (0, &cu, NULL, &origin_match, NULL, = &a); + } So with that I think my proposed patch in comment #3 might work. But I have not been able to replicate the issue. So cannot easily check. --=20 You are receiving this mail because: You are on the CC list for the bug.=