From 0643d299bcb482698681cee346033245ce52a3a2 Mon Sep 17 00:00:00 2001 From: Matt D'Souza Date: Tue, 11 Feb 2025 10:36:06 -0500 Subject: [PATCH] Remove AccessAdvisor assertions with data races --- .../oracle/svm/configure/trace/AccessAdvisor.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/trace/AccessAdvisor.java b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/trace/AccessAdvisor.java index b37b3a3a6934..48d147d30aee 100644 --- a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/trace/AccessAdvisor.java +++ b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/trace/AccessAdvisor.java @@ -259,7 +259,11 @@ public boolean matches(String otherJniFunction, String otherDeclaringClass, Stri public boolean shouldIgnoreJniLookup(String jniFunction, LazyValue queriedClass, LazyValue name, LazyValue signature, LazyValue callerClass, EconomicMap entry) { if (shouldIgnore(queriedClass, callerClass, entry)) { - throw new AssertionError("Must check shouldIgnore before shouldIgnoreJniLookup"); + // The live phase could have been changed concurrently after we checked shouldIgnore (we + // don't synchronize). If so, don't throw, and let logic below decide whether to ignore. + if (isInLivePhase) { + throw new AssertionError("Must check shouldIgnore before shouldIgnoreJniLookup"); + } } if (!heuristicsEnabled || launchPhase >= JNI_STARTUP_COMPLETE) { // Startup sequence completed (or we're not using the startup heuristics). @@ -307,7 +311,11 @@ public boolean shouldIgnoreResourceLookup(LazyValue resource, EconomicMa public boolean shouldIgnoreLoadClass(LazyValue queriedClass, LazyValue callerClass, EconomicMap entry) { if (shouldIgnore(queriedClass, callerClass, entry)) { - throw new AssertionError("Must check shouldIgnore before shouldIgnoreLoadClass"); + // The live phase could have been changed concurrently after we checked shouldIgnore (we + // don't synchronize). If so, don't throw, and let logic below decide whether to ignore. + if (isInLivePhase) { + throw new AssertionError("Must check shouldIgnore before shouldIgnoreLoadClass"); + } } if (!heuristicsEnabled) { return false;