This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Clarify StructuredDataImpl ownership
ClosedPublic

Authored by labath on Nov 30 2021, 5:37 AM.

Details

Summary

StructuredDataImpl ownership semantics is unclear at best. Various
structures were holding a non-owning pointer to it, with a comment that
the object is owned somewhere else. From what I was able to gather that
"somewhere else" was the SBStructuredData object, but I am not sure that
all created object eventually made its way there. (It wouldn't matter
even if they did, as we are leaking most of our SBStructuredData
objects.)

Since StructuredDataImpl is just a collection of two (shared) pointers,
there's really no point in elaborate lifetime management, so this patch
replaces all StructuredDataImpl pointers with actual objects or
unique_ptrs to it. This makes it much easier to resolve SBStructuredData
leaks in a follow-up patch.

Diff Detail

Event Timeline

labath created this revision.Nov 30 2021, 5:37 AM
labath requested review of this revision.Nov 30 2021, 5:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 30 2021, 5:37 AM
labath added inline comments.Nov 30 2021, 6:11 AM
lldb/source/API/SBThreadPlan.cpp
72–74

I haven't been able to figure out how/if this works. As far as I can tell, this object will get destroyed immediately after construction due to lack of any shared_ptrs pointing to it.

mib accepted this revision.Dec 1 2021, 8:12 PM

LGTM with some minor nits.

lldb/bindings/lua/lua-wrapper.swig
14

May be we should keep consistency with the python-wrapper.swig definition ?

lldb/source/API/SBThreadPlan.cpp
72–74

I agree in this case, m_opaque should be either a UP or SP but not a week_ptr.

This revision is now accepted and ready to land.Dec 1 2021, 8:12 PM
labath marked an inline comment as done.Dec 13 2021, 12:04 PM
labath added inline comments.
lldb/bindings/lua/lua-wrapper.swig
14

Good point. This actually uncovered that I was now leaking this StructuredDataImpl object.

This revision was automatically updated to reflect the committed changes.
labath marked an inline comment as done.