Skip to content

Commit b21d16b

Browse files
authored
Merge pull request #161 from bulasevich/GR-57835-1
[Backport][GR-57835] Remove dead threads from PolyglotContextImpl#threads during new thread initialization.
2 parents b5a9400 + d527ebf commit b21d16b

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
@@ -881,6 +881,14 @@ Object[] enterThreadChanged(boolean enterReverted, boolean pollSafepoint, boolea
881881
*/
882882
setCachedThreadInfo(PolyglotThreadInfo.NULL);
883883
}
884+
if (needsInitialization) {
885+
/*
886+
* A thread is added to the threads map only by the thread itself, so when
887+
* the thread is in the map, and it is not alive, then it surely won't be
888+
* used ever again.
889+
*/
890+
threads.entrySet().removeIf(threadInfoEntry -> !threadInfoEntry.getKey().isAlive());
891+
}
884892
boolean transitionToMultiThreading = isSingleThreaded() && hasActiveOtherThread(true, false);
885893

886894
if (transitionToMultiThreading) {

0 commit comments

Comments
 (0)