[Bug libdw/29434] Memory leak in `dwarf_getscopes`
mark at klomp dot org
sourceware-bugzilla@sourceware.org
Wed Feb 22 17:18:51 GMT 2023
https://sourceware.org/bugzilla/show_bug.cgi?id=29434
--- Comment #17 from Mark Wielaard <mark at klomp dot org> ---
So the code here changed a little with this patch:
commit b7c7d8776ed46e2237d18fb15c6b72e83cfa259b
Author: Mark Wielaard <mark@klomp.org>
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 <mark@klomp.org>
Which makes the condition of the first check slightly different:
- if (result == 0 && a.scopes != NULL)
- result = __libdw_visit_scopes (0, &cu, NULL, &origin_match, NULL, &a);
+ if (result >= 0 && a.scopes != 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 = CUDIE (a.inlined_origin.cu);
+ result = __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.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Elfutils-devel
mailing list