This is an archive of the discontinued LLVM Phabricator instance.

[dsymutil] Fix memory issue in the BinaryHolder
ClosedPublic

Authored by JDevlieghere on Apr 27 2022, 3:46 PM.

Details

Summary

The BinaryHolder has two caches for object and archive entries. These are implemented as StringMaps of ObjectEntry and ArchiveEntry respectively. The fact that they're stored by value is problematic because the BinaryHolder hands out references that become invalidate when the data structure grows. This patch wraps those object instances in unique pointers and changes the interface to hand out pointers. This resulted in transient failures

Diff Detail

Unit TestsFailed

Event Timeline

JDevlieghere created this revision.Apr 27 2022, 3:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2022, 3:46 PM
JDevlieghere requested review of this revision.Apr 27 2022, 3:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2022, 3:46 PM
vsk added inline comments.Apr 27 2022, 4:00 PM
llvm/tools/dsymutil/BinaryHolder.cpp
228–229

I think we can end up with two distinct ObjectEntry's (at different addresses) for the same {filename, timestamp} key, because archive loading is racy. Is that ok?

JDevlieghere marked an inline comment as done.Apr 27 2022, 4:21 PM
JDevlieghere added inline comments.
llvm/tools/dsymutil/BinaryHolder.cpp
228–229

That's a good point. I guess there's no better way to avoid that than by locking the during the whole loading sequence.

JDevlieghere marked an inline comment as done.

Lock during the whole load sequence

vsk added inline comments.Apr 27 2022, 4:28 PM
llvm/tools/dsymutil/BinaryHolder.cpp
228–229

I can't think of a better option.

vsk accepted this revision.Apr 27 2022, 4:29 PM

Thanks, lgtm.

This revision is now accepted and ready to land.Apr 27 2022, 4:29 PM
vsk added inline comments.Apr 27 2022, 4:30 PM
llvm/tools/dsymutil/BinaryHolder.cpp
2

?

vsk added inline comments.Apr 27 2022, 4:31 PM
llvm/tools/dsymutil/BinaryHolder.cpp
180

This comment might be stale now.

This revision was landed with ongoing or failed builds.Apr 27 2022, 4:35 PM
This revision was automatically updated to reflect the committed changes.
JDevlieghere marked an inline comment as done.