Skip to content

Commit cbc5a97

Browse files
committed
[GR-31987] Fix debug stepping can cause stack overflow errors for compiled call targets.
PullRequest: graal/9104
2 parents eb6cc75 + 8234931 commit cbc5a97

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

compiler/src/org.graalvm.compiler.truffle.runtime/src/org/graalvm/compiler/truffle/runtime/OptimizedCallTarget.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,9 +535,11 @@ protected final Object callBoundary(Object[] args) {
535535
}
536536

537537
private boolean interpreterCall() {
538+
boolean bypassedInstalledCode = false;
538539
if (isValid()) {
539540
// Native entry stubs were deoptimized => reinstall.
540541
runtime().bypassedInstalledCode(this);
542+
bypassedInstalledCode = true;
541543
}
542544
ensureInitialized();
543545
int intCallCount = this.callCount;
@@ -547,7 +549,16 @@ private boolean interpreterCall() {
547549

548550
// Check if call target is hot enough to compile
549551
if (shouldCompileImpl(intCallCount, intLoopCallCount)) {
550-
return compile(!engine.multiTier);
552+
boolean isCompiled = compile(!engine.multiTier);
553+
/*
554+
* If we bypassed the installed code chances are high that the code is currently being
555+
* debugged. This means that returning true for the interpreter call will retry the call
556+
* boundary. If the call boundary is retried and debug stepping would invalidate the
557+
* entry stub again then this leads to an inconvenient stack overflow error. In order to
558+
* avoid this we just do not return true and wait for the second execution to jump to
559+
* the optimized code. In practice the installed code should rarely be bypassed.
560+
*/
561+
return isCompiled && !bypassedInstalledCode;
551562
}
552563
return false;
553564
}

0 commit comments

Comments
 (0)