Skip to content

Commit

Permalink
Clear vmthread from thread object at shutdown
Browse files Browse the repository at this point in the history
Related to: eclipse-openj9#16659

Signed-off-by: tajila <[email protected]>
  • Loading branch information
tajila committed Oct 25, 2023
1 parent 06c3abc commit 36d6391
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions jcl/src/java.base/share/classes/java/lang/Thread.java
Original file line number Diff line number Diff line change
Expand Up @@ -1550,29 +1550,32 @@ void uncaughtException(Throwable e) {
* @see J9VMInternals#threadCleanup()
*/
void exit() {
try {
/*[IF JAVA_SPEC_VERSION >= 14]*/
/* Refresh deadInterrupt value so it is accurate when thread reference is removed. */
deadInterrupt = interrupted();
/* Refresh deadInterrupt value so it is accurate when thread reference is removed. */
deadInterrupt = interrupted();
/*[ENDIF] JAVA_SPEC_VERSION >= 14 */

/*[IF Sidecar18-SE-OpenJ9]*/
if ((threadLocals != null) && TerminatingThreadLocal.REGISTRY.isPresent()) {
TerminatingThreadLocal.threadTerminated();
}
if ((threadLocals != null) && TerminatingThreadLocal.REGISTRY.isPresent()) {
TerminatingThreadLocal.threadTerminated();
}
/*[ENDIF] Sidecar18-SE-OpenJ9 */

/*[PR 97317]*/
group = null;

/*[PR CVMC 118827] references are not removed in dead threads */
runnable = null;
inheritedAccessControlContext = null;
/*[PR 97317]*/
group = null;

threadLocals = null;
inheritableThreadLocals = null;
/*[PR CVMC 118827] references are not removed in dead threads. */
runnable = null;
inheritedAccessControlContext = null;

synchronized(lock) {
threadRef = Thread.NO_REF; // So that isAlive() can work
threadLocals = null;
inheritableThreadLocals = null;
} finally {
synchronized(lock) {
// So that isAlive() can work.
threadRef = Thread.NO_REF;
}
}
}

Expand Down

0 comments on commit 36d6391

Please sign in to comment.