Skip to content

Commit

Permalink
Fix debug stepping can cause stack overflow errors for compiled call …
Browse files Browse the repository at this point in the history
…targets. (GR-31987)

(cherry picked from commit 8234931)
  • Loading branch information
chumer authored and abdelhaira committed Jun 22, 2021
1 parent 53ab939 commit 31696a0
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,11 @@ protected final Object callBoundary(Object[] args) {
}

private boolean interpreterCall() {
boolean bypassedInstalledCode = false;
if (isValid()) {
// Native entry stubs were deoptimized => reinstall.
runtime().bypassedInstalledCode(this);
bypassedInstalledCode = true;
}
ensureInitialized();
int intCallCount = this.callCount;
Expand All @@ -495,7 +497,16 @@ private boolean interpreterCall() {

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

0 comments on commit 31696a0

Please sign in to comment.