From 0e690701448fce621646c560a6bfe685b9595873 Mon Sep 17 00:00:00 2001 From: Sacha Coppey Date: Tue, 11 Feb 2025 23:25:27 +0100 Subject: [PATCH] Fix concurrency issue with base layer graphs --- .../src/com/oracle/graal/pointsto/meta/AnalysisMethod.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); }; }