Skip to content

Changes

Summary

  1. analysis: Fix leaks in call stack tests and analysis waitForCompletion (details)
Commit 16f9917a46bdf361d7807836e49f1b6251f6e2cd by Patrick Tasse
analysis: Fix leaks in call stack tests and analysis waitForCompletion

In unit tests that extend CallStackTestBase, the CallGraphAnalysis gets
a CompositeHostModel that is never disposed.

The models can be disposed in the @After method of the test, however for
this to work, the analysis must be completed before the test ends.

In CallStackTestBase, the @Before method schedules the
CallStackAnalysisStub(InstrumentedCallStackAnalysis) and waits for its
completion before executing the test.

However, when the InstrumentedCallStackAnalysis completes its execution,
it schedules a CallGraphAnalysis and does not wait for its completion.
This can cause the model to be created after the test has completed and
attempted to dispose the models, and causes a leak.

The InstrumentedCallStackAnalysis waitForCompletion methods should
additionally wait for completion of the CallGraphAnalysis.

However, the CallGraphAnalysis is setup to have the
InstrumentedCallStackAnalysis as a dependent analysis, so this now
causes a deadlock as each analysis is waiting for the other to complete.

Normally an analysis that has dependent analyses will schedule these and
wait for completion before executing itself. But in this case it is the
InstrumentedCallStackAnalysis that executes to completion before
scheduling the CallGraphAnalysis, so the latter does not need to have
the former as a dependent analysis.

In other tests that do not extend CallStackTestBase, dispose the models
in the @After method.

Change-Id: I154d9d1eda7ca43740191f7fda34786c53f69b05
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/202591
Tested-by: Marco Miller <marco.miller@ericsson.com>
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Reviewed-by: Marco Miller <marco.miller@ericsson.com>
The file was modified analysis/org.eclipse.tracecompass.analysis.callstack.core/src/org/eclipse/tracecompass/internal/analysis/callstack/core/instrumented/InstrumentedCallStackAnalysis.java (diff)
The file was modified analysis/org.eclipse.tracecompass.analysis.callstack.core/src/org/eclipse/tracecompass/internal/analysis/callstack/core/callgraph/CallGraphAnalysis.java (diff)
The file was modified analysis/org.eclipse.tracecompass.analysis.callstack.core.tests/src/org/eclipse/tracecompass/analysis/callstack/core/tests/callgraph/AggregatedCalledFunctionStatisticsTest.java (diff)
The file was modified analysis/org.eclipse.tracecompass.analysis.callstack.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/callstack/ui/swtbot/tests/FlameGraphTest.java (diff)
The file was modified analysis/org.eclipse.tracecompass.analysis.callstack.core.tests/src/org/eclipse/tracecompass/analysis/callstack/core/tests/CallStackTestBase.java (diff)
The file was modified analysis/org.eclipse.tracecompass.analysis.callstack.core.tests/src/org/eclipse/tracecompass/analysis/callstack/core/tests/callgraph/CalledFunctionTest.java (diff)
The file was modified analysis/org.eclipse.tracecompass.analysis.callstack.core.tests/src/org/eclipse/tracecompass/analysis/callstack/core/tests/callgraph/AggregationTreeTest.java (diff)