Skip to content

Commit 717373c

Browse files
Ignore crashed threads.
1 parent 7bba4be commit 717373c

File tree

9 files changed

+40
-4
lines changed

9 files changed

+40
-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
@@ -418,6 +418,10 @@ static void disableAndFlushForAllThreads() {
418418

419419
if (SubstrateOptions.MultiThreaded.getValue()) {
420420
for (IsolateThread vmThread = VMThreads.firstThread(); vmThread.isNonNull(); vmThread = VMThreads.nextThread(vmThread)) {
421+
if (VMThreads.SafepointBehavior.isCrashedThread(vmThread)) {
422+
/* Ignore crashed threads because the TLAB can be corrupt. */
423+
continue;
424+
}
421425
disableAndFlushForThread(vmThread);
422426
}
423427
} 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
@@ -906,6 +906,10 @@ public void printDiagnostics(Log log, ErrorContext context, int maxDiagnosticLev
906906
if (vmThread == CurrentIsolate.getCurrentThread()) {
907907
continue;
908908
}
909+
if (VMThreads.SafepointBehavior.isCrashedThread(vmThread)) {
910+
/* The Java frame anchors or the values on the stack may be corrupt. */
911+
continue;
912+
}
909913
if (printed >= MAX_THREADS_TO_PRINT) {
910914
log.string("... (truncated)").newline();
911915
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
@@ -306,6 +306,10 @@ private static void deoptimizeInRangeOperation(CodePointer fromIp, CodePointer t
306306
if (vmThread == CurrentIsolate.getCurrentThread()) {
307307
continue;
308308
}
309+
if (VMThreads.SafepointBehavior.isCrashedThread(vmThread)) {
310+
/* The Java frame anchors or the values on the stack may be corrupt. */
311+
continue;
312+
}
309313
StackFrameVisitor deoptVisitor = getStackFrameVisitor((Pointer) fromIp, (Pointer) toIp, deoptAll, vmThread);
310314
JavaStackWalker.walkThread(vmThread, deoptVisitor);
311315
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,11 @@ private static class GetAllThreadsOperation extends JavaVMOperation {
10371037
@Override
10381038
protected void operate() {
10391039
for (IsolateThread cur = VMThreads.firstThread(); cur.isNonNull(); cur = VMThreads.nextThread(cur)) {
1040+
if (VMThreads.SafepointBehavior.isCrashedThread(cur)) {
1041+
/* The Java frame anchors or the values on the stack may be corrupt. */
1042+
continue;
1043+
}
1044+
10401045
Thread thread = PlatformThreads.fromVMThread(cur);
10411046
if (thread != null) {
10421047
result.add(thread);

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)