Skip to content

Commit 5754453

Browse files
committed
Fix: ReadCallerFrameNode did not handle the top correctly.
1 parent b493205 commit 5754453

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/ReadCallerFrameNode.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,11 @@ public PFrame executeWith(VirtualFrame frame, PFrame.Reference startFrameInfo, F
9898
PFrame.Reference callerInfo = curFrameInfo.getCallerInfo();
9999
if (callerInfo == null) {
100100
Frame callerFrame = getCallerFrame(startFrameInfo, frameAccess, skipInternal, level);
101-
ensureMaterializeNode().execute(frame, false, true, callerFrame);
102-
return PArguments.getCurrentFrameInfo(callerFrame).getPyFrame();
101+
if (callerFrame != null) {
102+
ensureMaterializeNode().execute(frame, false, true, callerFrame);
103+
return PArguments.getCurrentFrameInfo(callerFrame).getPyFrame();
104+
}
105+
return null;
103106
} else if (!(skipInternal && PRootNode.isPythonInternal(callerInfo.getCallNode().getRootNode()))) {
104107
i++;
105108
}
@@ -117,11 +120,14 @@ private PFrame.Reference walkLevels(VirtualFrame frame, PFrame.Reference startFr
117120
PFrame.Reference callerInfo = currentFrame.getCallerInfo();
118121
if (cachedCallerFrameProfile.profile(callerInfo == null)) {
119122
Frame callerFrame = getCallerFrame(startFrameInfo, frameAccess, skipInternal, level);
120-
// At this point, we must 'materialize' the frame. Actually, the Truffle frame is
121-
// never materialized but we ensure that a corresponding PFrame is created and that
122-
// the locals and arguments are synced.
123-
ensureMaterializeNode().execute(frame, false, true, callerFrame);
124-
return PArguments.getCurrentFrameInfo(callerFrame);
123+
if (callerFrame != null) {
124+
// At this point, we must 'materialize' the frame. Actually, the Truffle frame
125+
// is never materialized but we ensure that a corresponding PFrame is created
126+
// and that the locals and arguments are synced.
127+
ensureMaterializeNode().execute(frame, false, true, callerFrame);
128+
return PArguments.getCurrentFrameInfo(callerFrame);
129+
}
130+
return PFrame.Reference.EMPTY;
125131
} else if (!(skipInternal && PRootNode.isPythonInternal(callerInfo.getCallNode().getRootNode()))) {
126132
i++;
127133
}

0 commit comments

Comments
 (0)