diff options
author | Geneviève Bastien | 2018-05-01 17:29:43 +0000 |
---|---|---|
committer | Genevieve Bastien | 2018-05-02 20:18:31 +0000 |
commit | f429bde3e40c8ccc297b81cc343546c6b03c7ebf (patch) | |
tree | 035654f49333380a0f55ee5c181a5d109b039d21 /callstack/org.eclipse.tracecompass.incubator.callstack.core/src | |
parent | fd68941c8c672f55f2a9b2ca09f059f7670560d8 (diff) | |
download | org.eclipse.tracecompass.incubator-f429bde3e40c8ccc297b81cc343546c6b03c7ebf.tar.gz org.eclipse.tracecompass.incubator-f429bde3e40c8ccc297b81cc343546c6b03c7ebf.tar.xz org.eclipse.tracecompass.incubator-f429bde3e40c8ccc297b81cc343546c6b03c7ebf.zip |
callstack: Fix callstack concurrency exceptions
The CallStackDepth class used by data provider should use the object ID
of the callstack in its hash code, as 2 objects will be equivalent if
they refer to the same callstack, no matter its content.
Also, avoid concurrency exceptions while building by synchronizing
access to attribute updates
Change-Id: Idb806ab30e9b6d063ecbdce2a94cb045e8404200
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/121975
Tested-by: CI Bot
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Diffstat (limited to 'callstack/org.eclipse.tracecompass.incubator.callstack.core/src')
2 files changed, 13 insertions, 5 deletions
diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/instrumented/CallStackDepth.java b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/instrumented/CallStackDepth.java index fbcf8da16..2a408e0cd 100644 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/instrumented/CallStackDepth.java +++ b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/instrumented/CallStackDepth.java @@ -59,7 +59,10 @@ public class CallStackDepth { @Override public int hashCode() { - return Objects.hashCode(fCallstack, fDepth); + // Compare with the actual callstack object, as the callstack's own hash may + // change as the callstack is built. Here, we are looking for the same object, + // no matter its content + return Objects.hashCode(System.identityHashCode(fCallstack), fDepth); } @Override @@ -68,7 +71,10 @@ public class CallStackDepth { return false; } CallStackDepth csd = (CallStackDepth) obj; - return Objects.equal(fCallstack, csd.fCallstack) && (fDepth == csd.fDepth); + // Compare with the actual callstack object, as the callstack's own hash may + // change as the callstack is built. Here, we are looking for the same object, + // no matter its content + return Objects.equal(System.identityHashCode(fCallstack), System.identityHashCode(csd.fCallstack)) && (fDepth == csd.fDepth); } @Override diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/instrumented/InstrumentedCallStackElement.java b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/instrumented/InstrumentedCallStackElement.java index 85d9ee65f..6d82ef60d 100644 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/instrumented/InstrumentedCallStackElement.java +++ b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/instrumented/InstrumentedCallStackElement.java @@ -236,9 +236,11 @@ public class InstrumentedCallStackElement extends CallStackElement { callstack = new CallStack(getStateSystem(), subAttributes, this, hostProvider, threadIdProvider); fCallstack = callstack; } else { - // Update the callstack if attributes were added - if (callstack.getMaxDepth() < subAttributes.size() ) { - callstack.updateAttributes(subAttributes); + synchronized (fCallstack) { + // Update the callstack if attributes were added + if (callstack.getMaxDepth() < subAttributes.size()) { + callstack.updateAttributes(subAttributes); + } } } return Objects.requireNonNull(callstack); |