Page MenuHomeFreeBSD

readelf(1): fix -wR option, memory leaks, and -wf minor bug
ClosedPublic

Authored by christos on Feb 7 2023, 5:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 10, 2:30 AM
Unknown Object (File)
Thu, Nov 7, 11:56 AM
Unknown Object (File)
Thu, Nov 7, 11:52 AM
Unknown Object (File)
Thu, Nov 7, 11:52 AM
Unknown Object (File)
Tue, Oct 29, 12:59 PM
Unknown Object (File)
Oct 16 2024, 1:00 PM
Unknown Object (File)
Oct 16 2024, 11:56 AM
Unknown Object (File)
Oct 16 2024, 11:56 AM
Subscribers

Details

Summary

Fixed broken -wR option, and various memory leaks. There's also
a memory leak in search_loclist_at() (-wo option) which I haven't
been able to fix.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Is there a PR or other reference?

Is there a PR or other reference?

Nothing that I can find after a quick search.

This revision is now accepted and ready to land.Feb 7 2023, 8:03 PM

Is there a PR or other reference?

For context, Christos is working on a libdwarf program which enumerates inline function call locations. The eventual goal is to embed that functionality into libdtrace, so that we can use the kinst provider to probe inline function calls and returns.

christos retitled this revision from readelf(1): fix -wR option to readelf(1): fix -wR option, -wL memory leak, and -wf minor bug.
christos edited the summary of this revision. (Show Details)
This revision now requires review to proceed.Feb 9 2023, 4:29 AM
contrib/elftoolchain/readelf/readelf.c
5197

Are we still leaking the DIE in these error cases?

contrib/elftoolchain/readelf/readelf.c
5197

Are we still leaking the DIE in these error cases?

No, as far as I know, deallocating the srcfiles with DW_DLA_STRING is a NOP in FreeBSD's implementation. Libdwarf takes care of this.

contrib/elftoolchain/readelf/readelf.c
5197

Scratch that, I thought you meant something else.
Well, in this case, perhaps we can try deallocating the DIE before continuing.

christos retitled this revision from readelf(1): fix -wR option, -wL memory leak, and -wf minor bug to readelf(1): fix -wR option, memory leaks, and -wf minor bug.
christos edited the summary of this revision. (Show Details)
contrib/elftoolchain/readelf/readelf.c
4942

Where does this DIE get freed in the non-error case?

5201

Note that these continues apply to the inner for loop, so there's no leak. It's not clear to me that breaking out of the inner loop is the right thing to do?

christos added inline comments.
contrib/elftoolchain/readelf/readelf.c
5201

You're right. The dwarf_dealloc() should apply only to the outer loop's continues.

christos marked an inline comment as done.
This revision is now accepted and ready to land.Feb 15 2023, 2:40 PM