Skip to content

Commit

Permalink
Acquire interruptLock for interruptImpl and isInterruptedImpl
Browse files Browse the repository at this point in the history
interruptImpl and isInterruptedImpl use the eetop/threadRef value.
Acquiring interruptLock assures that the eetop/threadRef value won't
change during interruptImpl and isInterruptedImpl. This will prevent
crashes which happen when a stale eetop/threadRef value is used to
invoke OMR thread library functions.

Related: eclipse-openj9/openj9#19544
Related: eclipse-openj9/openj9#19598

Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
  • Loading branch information
babsingh committed Jun 18, 2024
1 parent e4d7f3c commit 2032314
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/java.base/share/classes/java/lang/Thread.java
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,9 @@ public static boolean interrupted() {
public boolean isInterrupted() {
// use fully qualified name to avoid ambiguous class error
if (com.ibm.oti.vm.VM.isJVMInSingleThreadedMode()) {
return isInterruptedImpl();
synchronized (interruptLock) {
return isInterruptedImpl();
}
}
return interrupted;
}
Expand Down Expand Up @@ -3031,7 +3033,9 @@ private void setPriority0(int newPriority) {
}

private void interrupt0() {
interruptImpl();
synchronized (interruptLock) {
interruptImpl();
}
}

private static void clearInterruptEvent() {
Expand Down

0 comments on commit 2032314

Please sign in to comment.