This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Remove orphaned modules in a loop
ClosedPublic

Authored by teemperor on Jul 17 2020, 3:58 AM.

Details

Summary

When modules reference each other (which happens for example with the different modules LLDB loads
when debugging -gmodules-compiled binaries), just iterating over the module list once isn't good enough
to find all orphans. Any removed modules in the module list will also clear up the shared pointers they
hold to other modules, so after any module was removed from the list, LLDB should iterate again and
check if any additional modules can no be safely deleted.

This is currently causing that many gmodules tests are not cleaning up all allocated modules which causes
cleanup asserts to fail (right now these asserts just mark the test as unsupported, but after D83865 the
tests will start failing).

Diff Detail

Event Timeline

teemperor created this revision.Jul 17 2020, 3:58 AM
JDevlieghere accepted this revision.Jul 17 2020, 8:23 AM

Makes sense, the RemoveOrphans should be idempotent if nothing else changed.

This revision is now accepted and ready to land.Jul 17 2020, 8:23 AM
aprantl added inline comments.Jul 17 2020, 10:07 AM
lldb/source/Core/ModuleList.cpp
298
bool made_progress = false;
while (!made_progress) {
  ...
}
teemperor updated this revision to Diff 279143.Jul 20 2020, 1:46 AM
teemperor marked an inline comment as done.
  • Refactored loop away from while (true) (thanks Adrian!)
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2020, 1:48 AM
shafik added a subscriber: shafik.Jul 20 2020, 10:20 AM

Thank you for this fix!