Skip to content

Commit 705b478

Browse files
committed
avoid holding on a not alive Thread in GilReleaseScheduler
1 parent 3eefc32 commit 705b478

File tree

1 file changed

+11
-3
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime

1 file changed

+11
-3
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/AsyncHandler.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
import com.oracle.graal.python.builtins.objects.function.PArguments;
6060
import com.oracle.graal.python.builtins.objects.function.Signature;
6161
import com.oracle.graal.python.nodes.PRootNode;
62-
import com.oracle.graal.python.nodes.call.CallNode;
6362
import com.oracle.graal.python.nodes.call.CallDispatchers;
63+
import com.oracle.graal.python.nodes.call.CallNode;
6464
import com.oracle.graal.python.nodes.frame.ReadCallerFrameNode;
6565
import com.oracle.graal.python.runtime.ExecutionContext.CalleeContext;
6666
import com.oracle.graal.python.runtime.exception.ExceptionUtils;
@@ -388,15 +388,23 @@ protected void perform(ThreadLocalAction.Access access) {
388388
}
389389
}
390390
});
391-
} else if (gilOwner != lastGilOwner) {
391+
} else if (gilOwner != lastGilOwner && gilOwner.isAlive()) {
392392
/*
393393
* If the gil changed owner since the last time we observed it, clear the
394394
* flag to make sure we don't get stuck if the last owner exits before
395395
* executing the safepoint.
396396
*/
397397
gilReleaseRequested = false;
398398
}
399-
lastGilOwner = gilOwner;
399+
if (gilOwner.isAlive()) {
400+
lastGilOwner = gilOwner;
401+
} else {
402+
/*
403+
* we should only store the thread if the thread is still alive, otherwise,
404+
* we will be referring to an object that should have been collected.
405+
*/
406+
lastGilOwner = null;
407+
}
400408
}
401409
}
402410
}

0 commit comments

Comments
 (0)