Skip to content

Commit ffe4764

Browse files
committed
[GR-39181] Avoid invalid/destroyed (libgraal) compiler isolates in purgePartialEvaluationCaches.
PullRequest: graal/11984
2 parents c49cd14 + f7905fd commit ffe4764

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

compiler/src/org.graalvm.compiler.truffle.runtime.hotspot.libgraal/src/org/graalvm/compiler/truffle/runtime/hotspot/libgraal/LibGraalHotSpotTruffleCompiler.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.graalvm.compiler.truffle.common.hotspot.HotSpotTruffleCompiler;
3838
import org.graalvm.compiler.truffle.runtime.GraalTruffleRuntime;
3939
import org.graalvm.compiler.truffle.runtime.OptimizedCallTarget;
40+
import org.graalvm.libgraal.DestroyedIsolateException;
4041
import org.graalvm.libgraal.LibGraal;
4142
import org.graalvm.libgraal.LibGraalObject;
4243
import org.graalvm.libgraal.LibGraalScope;
@@ -199,7 +200,19 @@ private static Supplier<Map<String, Object>> optionsEncoder(CompilableTruffleAST
199200
@SuppressWarnings("try")
200201
public void purgePartialEvaluationCaches() {
201202
try (LibGraalScope scope = new LibGraalScope(LibGraalScope.DetachAction.DETACH_RUNTIME_AND_RELEASE)) {
202-
TruffleToLibGraalCalls.purgePartialEvaluationCaches(getIsolateThread(), handle());
203+
try {
204+
long compilerHandle = handle();
205+
TruffleToLibGraalCalls.purgePartialEvaluationCaches(getIsolateThread(), compilerHandle);
206+
} catch (DestroyedIsolateException e) {
207+
// Truffle compiler threads (trying to purge PE caches) may race during VM exit with
208+
// the compiler isolate teardown. DestroyedIsolateException is only expected to be
209+
// observed here during VM exit; where it can be safely ignored.
210+
if (e.isVmExit()) {
211+
// ignore
212+
} else {
213+
throw e;
214+
}
215+
}
203216
}
204217
}
205218
}

0 commit comments

Comments
 (0)