tmf: Deadlock closing a trace as a signal is calling getAnalysisModules
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Sun, 19 Feb 2017 05:47:39 +0000 (00:47 -0500)
committerMarc-André Laperle <marc-andre.laperle@ericsson.com>
Tue, 21 Feb 2017 16:33:13 +0000 (11:33 -0500)
When a trace is opened, a traceRangeUpdated signal is sent
asynchronously. Depending on when this thread starts running, the trace
might open and the user might close the trace before it starts.

-The trace cannot finish disposing before the signal is finished because
when it tries to dispose its analysis, they unregister themselves from
the signal manager, but TmfSignalManager.unregister is synchronized
-The signal cannot finish because it is waiting for the lock on the
analysis map (being iterated in the dispose thread).

Here is an illustration of it:
Thread 1 (dispose): > analysis map lock > waiting on signal manager lock
Thread 2 (signal) > signal manager lock > waiting on analysis map lock

Bug: 512394
Change-Id: I0f27aa6c976a54368f79cd885a561c6ce8ac3dba
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/91427
Reviewed-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTrace.java

index f7902d4f7992e22c544197ba48bf14674117f44a..dc9af7e2193e999686ae3a55cc51663b19c7a393 100644 (file)
@@ -340,12 +340,11 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
         }
 
         /* Clean up the analysis modules */
-        synchronized (fAnalysisModules) {
-            for (IAnalysisModule module : fAnalysisModules.values()) {
-                module.dispose();
-            }
-            fAnalysisModules.clear();
+        Iterable<IAnalysisModule> analysisModules = getAnalysisModules();
+        for (IAnalysisModule module : analysisModules) {
+            module.dispose();
         }
+        fAnalysisModules.clear();
 
         super.dispose();
     }
This page took 0.027707 seconds and 5 git commands to generate.