This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Fix leak in test
ClosedPublic

Authored by vitalybuka on Jun 10 2021, 6:43 PM.

Details

Summary

Test leaks if we run
tools/lldb/unittests/Host/HostTests without --gtest_filter

Diff Detail

Event Timeline

vitalybuka requested review of this revision.Jun 10 2021, 6:43 PM
vitalybuka created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2021, 6:43 PM
vitalybuka retitled this revision from [NFC] Fix leak in test to [NFC][lldb] Fix leak in test.Jun 10 2021, 6:47 PM
vitalybuka added reviewers: shafik, JDevlieghere, labath.
vitalybuka edited the summary of this revision. (Show Details)
teemperor requested changes to this revision.Jun 10 2021, 11:45 PM
teemperor added a subscriber: teemperor.

I think we should instead implement the Terminate function that the plugin system provides to tear down our state. I made a patch in D104093 that
moves the once_flags to the internal state struct, so with a proper Terminate implementation + my patch this should all work properly.

HostInfoLinux::Terminate() {
  assert(g_fields && "Missing call to Initialize?");
  delete g_fields;
  g_fields = nullptr;
  HostInfoBase::Terminate();
}
lldb/source/Host/linux/HostInfoLinux.cpp
38

Please instead add a HostInfoLinux::Terminate() function that deletes and zeroes g_fields (see HostInfoBase::Terminate). Initialize -> Terminate should set up and tear down the data structures if possible (not saying that LLDB is doing this consistently at the moment, but that's the idea at least).

This revision now requires changes to proceed.Jun 10 2021, 11:45 PM
teemperor added inline comments.Jun 10 2021, 11:47 PM
lldb/unittests/Host/HostInfoTest.cpp
64

HostInfoTestInitialization maybe?

vitalybuka retitled this revision from [NFC][lldb] Fix leak in test to [lldb] Fix leak in test.Jun 11 2021, 12:03 AM
vitalybuka edited the summary of this revision. (Show Details)
vitalybuka marked 2 inline comments as done.
vitalybuka edited the summary of this revision. (Show Details)

::Terminate

teemperor accepted this revision.Jun 11 2021, 12:05 AM

LGTM, big thanks for the patch & quick turnaround!

This revision is now accepted and ready to land.Jun 11 2021, 12:05 AM
This revision was landed with ongoing or failed builds.Jun 11 2021, 12:20 AM
This revision was automatically updated to reflect the committed changes.