[Lldb-commits] [PATCH] D13788: Factor the execution of a test method into its own function to ensure proper cleanup

Adrian McCarthy via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 15 14:56:50 PDT 2015

amccarth created this revision.
amccarth added a reviewer: tfiala.
amccarth added a subscriber: lldb-commits.

This solves problems in tearDown of individual test cases, which were especially noticeable on Windows.

When a test throws an exception, the exception retains references to the functions in the stack, which in term keeps their local variables alive.  When those locals are SB proxy objects, cleanup doesn't proceed as it should because they keep LLDB objects alive that should have been orphaned.

By moving the running of the test method to a separate function, we ensure that the exception goes out of scope before we attempt tearDown, and the gc.collect() makes sure the orphaned objects are properly destroyed before the framework attempts to delete the target.

Without this fix, a test case that throws might cause the shared module list to retain an open handle to the inferior, even after the target is deleted.  This affects the state of subsequent test cases in the same test.  This was especially noticeable on Windows in tests like TestTargetAPI, because the open handle prevented make from deleting the inferior after the failed test case and the next test case from re-building the inferior.  Thus nearly all tests cases would fail because of a problem in just one.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13788.37523.patch
Type: text/x-patch
Size: 4979 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20151015/c2172ed3/attachment.bin>

More information about the lldb-commits mailing list