From ae5a8d29aea7cf58854427d3e47fea8775bc6e29 Mon Sep 17 00:00:00 2001 From: Florian Angerer <florian.angerer@oracle.com> Date: Mon, 21 Aug 2017 11:44:01 +0200 Subject: [PATCH] Fix: Race when using lookup result. --- .../access/variables/ReadVariableNode.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/variables/ReadVariableNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/variables/ReadVariableNode.java index 09fd6d1280..338251a3ff 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/variables/ReadVariableNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/variables/ReadVariableNode.java @@ -619,18 +619,17 @@ public final class ReadVariableNode extends RBaseNode { LookupResult lookup = FrameSlotChangeMonitor.lookup(variableFrame, identifier); if (lookup != null) { try { - if (lookup.getValue() instanceof RPromise) { - evalPromiseSlowPathWithName(identifierAsString, frame, (RPromise) lookup.getValue()); + Object value = lookup.getValue(); + if (value instanceof RPromise) { + evalPromiseSlowPathWithName(identifierAsString, frame, (RPromise) value); } - if (lookup != null) { - if (lookup instanceof FrameAndSlotLookupResult) { - if (checkTypeSlowPath(frame, lookup.getValue())) { - return new FrameAndSlotLookupLevel((FrameAndSlotLookupResult) lookup); - } - } else { - if (lookup.getValue() == null || checkTypeSlowPath(frame, lookup.getValue())) { - return new LookupLevel(lookup); - } + if (lookup instanceof FrameAndSlotLookupResult) { + if (checkTypeSlowPath(frame, value)) { + return new FrameAndSlotLookupLevel((FrameAndSlotLookupResult) lookup); + } + } else { + if (value == null || checkTypeSlowPath(frame, value)) { + return new LookupLevel(lookup); } } } catch (InvalidAssumptionException e) { -- GitLab