Skip to content

Commit e0e4bce

Browse files
committed
Fix: Do not call exception hook with non-Python frame.
1 parent 2aa3cab commit e0e4bce

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/control/TopLevelExceptionHandler.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public class TopLevelExceptionHandler extends RootNode {
9494

9595
@Child private CreateArgumentsNode createArgs = CreateArgumentsNode.create();
9696
@Child private LookupAndCallUnaryNode callStrNode = LookupAndCallUnaryNode.create(__STR__);
97-
@Child private CallNode callNode = CallNode.create();
97+
@Child private CallNode exceptionHookCallNode = CallNode.create();
9898
@Child private MaterializeFrameNode materializeFrameNode = MaterializeFrameNodeGen.create();
9999
@Child private PythonObjectFactory factory;
100100
@Child private GetTracebackNode getTracebackNode;
@@ -187,7 +187,10 @@ private void printExc(VirtualFrame frame, PException e) {
187187
if (PythonOptions.getOption(theContext, PythonOptions.AlwaysRunExcepthook)) {
188188
if (hook != PNone.NO_VALUE) {
189189
try {
190-
callNode.execute(frame, hook, new Object[]{type, value, tb}, PKeyword.EMPTY_KEYWORDS);
190+
// Note: it is important to pass frame 'null' because that will cause the
191+
// CallNode to tread the invoke like a foreign call and access the top frame ref
192+
// in the context.
193+
exceptionHookCallNode.execute(null, hook, new Object[]{type, value, tb}, PKeyword.EMPTY_KEYWORDS);
191194
} catch (PException internalError) {
192195
// More complex handling of errors in exception printing is done in our
193196
// Python code, if we get here, we just fall back to the launcher

0 commit comments

Comments
 (0)