Skip to content

Commit 9164c0b

Browse files
committed
Add missing fence and assert ownsGil() where appropriate
1 parent c51cb85 commit 9164c0b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContext.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import static com.oracle.graal.python.util.PythonUtils.tsArray;
4848

4949
import java.io.IOException;
50+
import java.lang.invoke.VarHandle;
5051
import java.lang.ref.Reference;
5152
import java.lang.ref.ReferenceQueue;
5253
import java.lang.ref.WeakReference;
@@ -497,7 +498,9 @@ public void execute(PythonContext context) {
497498
private RootCallTarget getReferenceCleanerCallTarget() {
498499
if (referenceCleanerCallTarget == null) {
499500
CompilerDirectives.transferToInterpreterAndInvalidate();
500-
referenceCleanerCallTarget = PythonUtils.getOrCreateCallTarget(new HPyNativeSpaceCleanerRootNode(getContext()));
501+
RootCallTarget localTarget = PythonUtils.getOrCreateCallTarget(new HPyNativeSpaceCleanerRootNode(getContext()));
502+
VarHandle.storeStoreFence();
503+
referenceCleanerCallTarget = localTarget;
501504
}
502505
return referenceCleanerCallTarget;
503506
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ public Signature getSignature(Node inliningTarget, InlinedConditionProfile signa
591591

592592
@TruffleBoundary
593593
synchronized Signature initializeSignature(RootCallTarget rootCallTarget) {
594+
assert PythonContext.get(null).ownsGil(); // otherwise this is racy
594595
if (signature == null) {
595596
if (rootCallTarget.getRootNode() instanceof PRootNode) {
596597
signature = ((PRootNode) rootCallTarget.getRootNode()).getSignature();
@@ -610,6 +611,7 @@ private RootCallTarget getRootCallTarget() {
610611

611612
@TruffleBoundary
612613
synchronized RootCallTarget initializeCallTarget() {
614+
assert PythonContext.get(null).ownsGil(); // otherwise this is racy
613615
if (callTarget == null) {
614616
callTarget = (RootCallTarget) callTargetSupplier.get();
615617
callTargetSupplier = null;

0 commit comments

Comments
 (0)