Skip to content

Commit 273e73f

Browse files
Ignore crashed threads.
1 parent 6ffac72 commit 273e73f

File tree

9 files changed

+39
-4
lines changed

9 files changed

+39
-4
lines changed

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GCImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,10 @@ private void blackenStackRoots() {
865865
*/
866866
continue;
867867
}
868+
if (VMThreads.SafepointBehavior.isCrashedThread(vmThread)) {
869+
/* The Java frame anchors or the values on the stack may be corrupt. */
870+
continue;
871+
}
868872
if (JavaStackWalker.initWalk(walk, vmThread)) {
869873
walkStack(walk);
870874
}

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/StackVerifier.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ public static boolean verifyAllThreads() {
6161
if (vmThread == CurrentIsolate.getCurrentThread()) {
6262
continue;
6363
}
64+
if (VMThreads.SafepointBehavior.isCrashedThread(vmThread)) {
65+
/* The Java frame anchors or the values on the stack may be corrupt. */
66+
continue;
67+
}
6468
JavaStackWalker.walkThread(vmThread, STACK_FRAME_VISITOR);
6569
}
6670
}

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ThreadLocalAllocation.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,10 @@ static void disableAndFlushForAllThreads() {
409409

410410
if (SubstrateOptions.MultiThreaded.getValue()) {
411411
for (IsolateThread vmThread = VMThreads.firstThread(); vmThread.isNonNull(); vmThread = VMThreads.nextThread(vmThread)) {
412+
if (VMThreads.SafepointBehavior.isCrashedThread(vmThread)) {
413+
/* Ignore crashed threads because the TLAB can be corrupt. */
414+
continue;
415+
}
412416
disableAndFlushForThread(vmThread);
413417
}
414418
} else {

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/DumpThreadStacksOnSignalFeature.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ protected void operate() {
9292
/* Skip the signal handler stack */
9393
continue;
9494
}
95+
if (VMThreads.SafepointBehavior.isCrashedThread(vmThread)) {
96+
/* The Java frame anchors or the values on the stack may be corrupt. */
97+
continue;
98+
}
9599
try {
96100
dumpStack(log, vmThread);
97101
} catch (Exception e) {

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateDiagnostics.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,10 @@ public void printDiagnostics(Log log, ErrorContext context, int maxDiagnosticLev
907907
if (vmThread == CurrentIsolate.getCurrentThread()) {
908908
continue;
909909
}
910+
if (VMThreads.SafepointBehavior.isCrashedThread(vmThread)) {
911+
/* The Java frame anchors or the values on the stack may be corrupt. */
912+
continue;
913+
}
910914
if (printed >= MAX_THREADS_TO_PRINT) {
911915
log.string("... (truncated)").newline();
912916
break;

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/RuntimeCodeCache.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,10 @@ public boolean verify(CodeInfo info) {
302302
if (vmThread == CurrentIsolate.getCurrentThread()) {
303303
continue;
304304
}
305+
if (VMThreads.SafepointBehavior.isCrashedThread(vmThread)) {
306+
/* The Java frame anchors or the values on the stack may be corrupt. */
307+
continue;
308+
}
305309
JavaStackWalker.walkThread(vmThread, this);
306310
}
307311
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/deopt/Deoptimizer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,10 @@ private static void deoptimizeInRangeOperation(CodePointer fromIp, CodePointer t
307307
if (vmThread == CurrentIsolate.getCurrentThread()) {
308308
continue;
309309
}
310+
if (VMThreads.SafepointBehavior.isCrashedThread(vmThread)) {
311+
/* The Java frame anchors or the values on the stack may be corrupt. */
312+
continue;
313+
}
310314
StackFrameVisitor deoptVisitor = getStackFrameVisitor((Pointer) fromIp, (Pointer) toIp, deoptAll, vmThread);
311315
JavaStackWalker.walkThread(vmThread, deoptVisitor);
312316
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/PlatformThreads.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,10 @@ private static class GetAllThreadsOperation extends JavaVMOperation {
10151015
@Override
10161016
protected void operate() {
10171017
for (IsolateThread cur = VMThreads.firstThread(); cur.isNonNull(); cur = VMThreads.nextThread(cur)) {
1018+
if (VMThreads.SafepointBehavior.isCrashedThread(cur)) {
1019+
/* The Java frame anchors or the values on the stack may be corrupt. */
1020+
continue;
1021+
}
10181022
result.add(PlatformThreads.fromVMThread(cur));
10191023
}
10201024
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMThreads.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -866,13 +866,11 @@ public static int getSafepointBehaviorVolatile(IsolateThread vmThread) {
866866
* thread status).
867867
*
868868
* NOTE: Be careful with this method and make sure that this thread does not allocate any
869-
* Java objects as this could result deadlocks. This method will only work prevent
870-
* safepoints reliably if it is called from a thread with
871-
* {@link StatusSupport#STATUS_IN_JAVA}.
869+
* Java objects as this could result deadlocks. This method will only prevent safepoints
870+
* reliably if it is called from a thread with {@link StatusSupport#STATUS_IN_JAVA}.
872871
*/
873872
@Uninterruptible(reason = "Called from uninterruptible code.", callerMustBe = true)
874873
public static void preventSafepoints() {
875-
// It would be nice if we could retire the TLAB here but that wouldn't work reliably.
876874
safepointBehaviorTL.setVolatile(PREVENT_VM_FROM_REACHING_SAFEPOINT);
877875
}
878876

@@ -895,6 +893,11 @@ public static void markThreadAsCrashed() {
895893
safepointBehaviorTL.setVolatile(THREAD_CRASHED);
896894
}
897895

896+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
897+
public static boolean isCrashedThread(IsolateThread thread) {
898+
return safepointBehaviorTL.getVolatile(thread) == THREAD_CRASHED;
899+
}
900+
898901
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
899902
public static String toString(int safepointBehavior) {
900903
switch (safepointBehavior) {

0 commit comments

Comments
 (0)