diff --git a/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisMethod.java b/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisMethod.java index a3c2865128de..00ace3d66c06 100644 --- a/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisMethod.java +++ b/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisMethod.java @@ -1048,7 +1048,11 @@ public String toString() { static GraphCacheEntry createLockEntry(Stage stage, GraphCacheEntry base, ReentrantLock lock) { return switch (stage) { case BYTECODE_PARSED -> new GraphCacheEntry(lock, lock); - case OPTIMIZATIONS_APPLIED -> new GraphCacheEntry(base.bytecodeParsedObject, lock); + /* + * If the stage 1 is skipped, the first stage needs to be locked too, to avoid + * another thread stealing the unparsed state. + */ + case OPTIMIZATIONS_APPLIED -> base.bytecodeParsedObject == GRAPH_CACHE_UNPARSED ? new GraphCacheEntry(lock, lock) : new GraphCacheEntry(base.bytecodeParsedObject, lock); }; }