Skip to content

Commit cee5291

Browse files
committed
Fix racy initialization
1 parent 9a600de commit cee5291

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1756,11 +1756,20 @@ private Object callNativeGenericNewNode(Object self, Object[] varargs, PKeyword[
17561756

17571757
private void checkExcessArgs(Object type, Object[] varargs, PKeyword[] kwargs) {
17581758
if (varargs.length != 0 || kwargs.length != 0) {
1759-
if (profileInit == null) {
1759+
if (lookupNew == null) {
17601760
CompilerDirectives.transferToInterpreterAndInvalidate();
17611761
lookupNew = insert(LookupAttributeInMRONode.create(__NEW__));
1762+
}
1763+
if (lookupInit == null) {
1764+
CompilerDirectives.transferToInterpreterAndInvalidate();
17621765
lookupInit = insert(LookupAttributeInMRONode.create(__INIT__));
1766+
}
1767+
if (profileNew == null) {
1768+
CompilerDirectives.transferToInterpreterAndInvalidate();
17631769
profileNew = ValueProfile.createIdentityProfile();
1770+
}
1771+
if (profileInit == null) {
1772+
CompilerDirectives.transferToInterpreterAndInvalidate();
17641773
profileInit = ValueProfile.createIdentityProfile();
17651774
}
17661775
if (ObjectBuiltins.InitNode.overridesBuiltinMethod(type, profileNew, lookupNew, ObjectNode.class)) {

0 commit comments

Comments
 (0)