Skip to content

Commit 60e9ec6

Browse files
committed
applyDiffToTopNode() is called with negative 'diff' from undoDiffAtGetResultsMoment()
1 parent 766693d commit 60e9ec6

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

visualvm/libs.profiler/lib.profiler/src/org/graalvm/visualvm/lib/jfluid/results/cpu/StackTraceSnapshotBuilder.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -696,28 +696,30 @@ protected void applyDiffAtGetResultsMoment(ThreadInfo ti) {
696696
long time0 = getDumpAbsTimeStamp();
697697
long diff = time0 - ti.topMethodEntryTime0;
698698

699-
applyDiffToTopNode(ti, diff);
700-
ti.diffAtGetResultsMoment = diff;
699+
if (diff>0) {
700+
applyDiffToTopNode(ti, diff);
701+
ti.diffAtGetResultsMoment = diff;
702+
}
701703
}
702704

703705
@Override
704706
protected void undoDiffAtGetResultsMoment(ThreadInfo ti) {
705-
applyDiffToTopNode(ti, -ti.diffAtGetResultsMoment);
706-
ti.diffAtGetResultsMoment = 0;
707+
if (ti.diffAtGetResultsMoment>0) {
708+
applyDiffToTopNode(ti, -ti.diffAtGetResultsMoment);
709+
ti.diffAtGetResultsMoment = 0;
710+
}
707711
}
708712

709713
private void applyDiffToTopNode(ThreadInfo ti, long diff) {
710-
if (diff>0) {
711-
TimedCPUCCTNode top = ti.peek();
714+
TimedCPUCCTNode top = ti.peek();
712715

713-
if (top instanceof MethodCPUCCTNode) {
714-
top.addNetTime0(diff);
715-
if (isCollectingTwoTimeStamps()) {
716-
SampledThreadInfo sti = lastStackTrace.get().get(Long.valueOf(ti.threadId));
716+
if (top instanceof MethodCPUCCTNode) {
717+
top.addNetTime0(diff);
718+
if (isCollectingTwoTimeStamps()) {
719+
SampledThreadInfo sti = lastStackTrace.get().get(Long.valueOf(ti.threadId));
717720

718-
if (sti!=null && sti.getThreadState() == Thread.State.RUNNABLE) {
719-
top.addNetTime1(diff);
720-
}
721+
if (sti!=null && sti.getThreadState() == Thread.State.RUNNABLE) {
722+
top.addNetTime1(diff);
721723
}
722724
}
723725
}

0 commit comments

Comments
 (0)