Skip to content

Commit eb609df

Browse files
committed
Do not remove resurrected native object references.
1 parent 79e2ab9 commit eb609df

File tree

1 file changed

+12
-8
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi

1 file changed

+12
-8
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiContext.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,6 @@ public Object execute(VirtualFrame frame) {
318318
CalleeContext.enter(frame, customLocalsProfile);
319319
try {
320320
NativeObjectReference[] nativeObjectReferences = (NativeObjectReference[]) PArguments.getArgument(frame, 0);
321-
NativeObjectReference nativeObjectReference;
322321
int cleaned = 0;
323322
long allocatedNativeMem = cApiContext.allocatedMemory;
324323
long startTime = 0;
@@ -338,18 +337,23 @@ public Object execute(VirtualFrame frame) {
338337
}
339338

340339
for (int i = 0; i < n; i++) {
341-
nativeObjectReference = nativeObjectReferences[i];
342-
cApiContext.nativeObjectWrapperList.remove(nativeObjectReference.id);
340+
NativeObjectReference nativeObjectReference = nativeObjectReferences[i];
343341
Object pointerObject = nativeObjectReference.ptrObject;
344-
if (!nativeObjectReference.resurrect && !pointerObjectLib.isNull(pointerObject)) {
345-
cApiContext.checkAccess(pointerObject, pointerObjectLib);
346-
LOGGER.finer(() -> "Cleaning native object reference to " + CApiContext.asHex(pointerObject));
347-
cleaned++;
342+
if (!nativeObjectReference.resurrect) {
343+
cApiContext.nativeObjectWrapperList.remove(nativeObjectReference.id);
344+
if (!nativeObjectReference.resurrect && !pointerObjectLib.isNull(pointerObject)) {
345+
cApiContext.checkAccess(pointerObject, pointerObjectLib);
346+
LOGGER.finer(() -> "Cleaning native object reference to " + CApiContext.asHex(pointerObject));
347+
cleaned++;
348+
}
348349
}
349350
}
350351
} else {
351352
for (int i = 0; i < n; i++) {
352-
cApiContext.nativeObjectWrapperList.remove(nativeObjectReferences[i].id);
353+
NativeObjectReference nativeObjectReference = nativeObjectReferences[i];
354+
if (!nativeObjectReference.resurrect) {
355+
cApiContext.nativeObjectWrapperList.remove(nativeObjectReference.id);
356+
}
353357
}
354358
}
355359

0 commit comments

Comments
 (0)