tmf: Fix IndexOOB exception in HT node with concurrent read/write
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Tue, 8 Apr 2014 21:15:34 +0000 (17:15 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Wed, 9 Apr 2014 16:42:14 +0000 (12:42 -0400)
Similar to bug #432191, but with the History Tree backend. It's possible
for an attribute to be created, sent to the backend, and written to a
node, all while a query is ongoing. (That's a race condition where you
race a Formula 1 against a turtle, but the turtle somehow arrives first).

Simply ignore those new attributes, since their value at time 't' would be
null anyway.

Change-Id: I072a08e84795a321c3b2bb393d9880ac4ba13a6a
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/24674
Tested-by: Hudson CI
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HTNode.java

index b8a878022d8ece38627ab3b3751c17f9d9ef36a7..a81afe764e3a9c4369b75616e3fba2df06a3d87f 100644 (file)
@@ -389,10 +389,16 @@ public abstract class HTNode {
             for (int i = startIndex; i < intervals.size(); i++) {
                 /*
                  * Now we only have to compare the Start times, since we now the
-                 * End times necessarily fit
+                 * End times necessarily fit.
+                 *
+                 * Second condition is to ignore new attributes that might have
+                 * been created after stateInfo was instantiated (they would be
+                 * null anyway).
                  */
-                if (intervals.get(i).getStartTime() <= t) {
-                    stateInfo.set(intervals.get(i).getAttribute(), intervals.get(i));
+                ITmfStateInterval interval = intervals.get(i);
+                if (interval.getStartTime() <= t &&
+                        interval.getAttribute() < stateInfo.size()) {
+                    stateInfo.set(interval.getAttribute(), interval);
                 }
             }
         } finally {
This page took 0.026503 seconds and 5 git commands to generate.