Skip to content

Commit 259433a

Browse files
committed
[GR-57835] Remove dead threads from PolyglotContextImpl#threads during new thread initialization.
PullRequest: graal/18734
2 parents b2b58af + 4943435 commit 259433a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotContextImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,14 @@ Object[] enterThreadChanged(boolean enterReverted, boolean pollSafepoint, boolea
874874
*/
875875
setCachedThreadInfo(PolyglotThreadInfo.NULL);
876876
}
877+
if (needsInitialization) {
878+
/*
879+
* A thread is added to the threads map only by the thread itself, so when
880+
* the thread is in the map, and it is not alive, then it surely won't be
881+
* used ever again.
882+
*/
883+
threads.entrySet().removeIf(threadInfoEntry -> !threadInfoEntry.getKey().isAlive());
884+
}
877885
boolean transitionToMultiThreading = isSingleThreaded() && hasActiveOtherThread(true, false);
878886

879887
if (transitionToMultiThreading) {

0 commit comments

Comments
 (0)