Skip to content

Commit a6b0689

Browse files
committed
[GR-63549] Fix data race between swapOut and addPredicated in the TypeFlow class
PullRequest: graal/20442
2 parents 600624b + 38ddfcc commit a6b0689

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/PointsToAnalysis.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,10 @@ public boolean finish() throws InterruptedException {
650650
@Override
651651
public void afterAnalysis() {
652652
/*
653-
* Only verify in the context-insensitive configuration as context-sensitive analysis is not
653+
* Only verify in the context-insensitive analysis because context-sensitive analysis is not
654654
* compatible with predicates.
655655
*/
656-
assert !PointstoOptions.AnalysisContextSensitivity.getValue(options).equals("insens") || validateFixedPointState();
656+
assert analysisPolicy().isContextSensitiveAnalysis() || validateFixedPointState();
657657
}
658658

659659
/**

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/flow/TypeFlow.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -955,18 +955,21 @@ private void notifySaturated(PointsToAnalysis bb) {
955955

956956
/** This flow will swap itself out at all uses and observers. */
957957
protected void swapOut(PointsToAnalysis bb, TypeFlow<?> newFlow) {
958+
assert isSaturated() : "This operation should only be called on saturated flows:" + this;
958959
for (TypeFlow<?> use : getUses()) {
959960
swapAtUse(bb, newFlow, use);
960961
}
961962
for (TypeFlow<?> observer : getObservers()) {
962963
swapAtObserver(bb, newFlow, observer);
963964
}
965+
/*
966+
* Before performing the swap, make sure addPredicated will immediately enable any newly
967+
* added predicated flows.
968+
*/
969+
AtomicUtils.atomicMark(this, PREDICATE_TRIGGERED_UPDATER);
964970
for (TypeFlow<?> predicatedFlow : getPredicatedFlows()) {
965971
swapAtPredicated(bb, newFlow, predicatedFlow);
966972
}
967-
if (isSaturated()) {
968-
AtomicUtils.atomicMark(this, PREDICATE_TRIGGERED_UPDATER);
969-
}
970973
}
971974

972975
protected void swapAtUse(PointsToAnalysis bb, TypeFlow<?> newFlow, TypeFlow<?> use) {

0 commit comments

Comments
 (0)