Skip to content

Commit f072015

Browse files
committed
Fix: keep string wrapper alive
1 parent cfee5fe commit f072015

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotGetAttr.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GETATTR__;
4646
import static com.oracle.graal.python.runtime.exception.PythonErrorType.AttributeError;
4747

48+
import java.lang.ref.Reference;
49+
4850
import com.oracle.graal.python.PythonLanguage;
4951
import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.AsCharPointerNode;
5052
import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.ExternalFunctionInvokeNode;
@@ -263,6 +265,8 @@ static Object callNative(VirtualFrame frame, TpSlots slots, TpSlotNative slot, O
263265
} finally {
264266
if (isGetAttr) {
265267
freeNode.free(nameArg);
268+
} else {
269+
Reference.reachabilityFence(nameArg);
266270
}
267271
}
268272
return checkResultNode.execute(threadState, T___GETATTR__, toPythonNode.execute(result));

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSetAttr.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___DELATTR__;
4646
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SETATTR__;
4747

48+
import java.lang.ref.Reference;
49+
4850
import com.oracle.graal.python.PythonLanguage;
4951
import com.oracle.graal.python.builtins.Python3Core;
5052
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
@@ -281,6 +283,8 @@ static void callNative(VirtualFrame frame, TpSlots slots, TpSlotNative slot, Obj
281283
} finally {
282284
if (isSetAttr) {
283285
freeNode.free(nameArg);
286+
} else {
287+
Reference.reachabilityFence(nameArg);
284288
}
285289
}
286290
checkResultNode.execute(threadState, T___SETATTR__, result);

0 commit comments

Comments
 (0)