Skip to content

Commit 1bf366b

Browse files
Fix thread printing in fatal error diagnostics.
1 parent 79d04b5 commit 1bf366b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,8 @@ public int maxInvocationCount() {
657657
@Override
658658
@RestrictHeapAccess(access = RestrictHeapAccess.Access.NO_ALLOCATION, reason = "Must not allocate while printing diagnostics.")
659659
public void printDiagnostics(Log log, ErrorContext context, int maxDiagnosticLevel, int invocationCount) {
660-
boolean allowJavaHeapAccess = DiagnosticLevel.javaHeapAccessAllowed(maxDiagnosticLevel) && invocationCount < 3;
661-
boolean allowUnsafeOperations = DiagnosticLevel.unsafeOperationsAllowed(maxDiagnosticLevel) && invocationCount < 2;
660+
boolean allowJavaHeapAccess = DiagnosticLevel.javaHeapAccessAllowed(maxDiagnosticLevel) && invocationCount < 2;
661+
boolean allowUnsafeOperations = DiagnosticLevel.unsafeOperationsAllowed(maxDiagnosticLevel) && invocationCount < 3;
662662
/*
663663
* If we are not at a safepoint, then it is unsafe to access the thread locals of
664664
* another thread as the IsolateThread could be freed at any time.
@@ -680,9 +680,13 @@ public void printDiagnostics(Log log, ErrorContext context, int maxDiagnosticLev
680680

681681
if (allowJavaHeapAccess) {
682682
Thread threadObj = PlatformThreads.fromVMThread(thread);
683-
log.string(" \"").string(threadObj.getName()).string("\" - ").zhex(Word.objectToUntrackedPointer(threadObj));
684-
if (threadObj != null && threadObj.isDaemon()) {
685-
log.string(", daemon");
683+
if (threadObj == null) {
684+
log.string(" null");
685+
} else {
686+
log.string(" \"").string(threadObj.getName()).string("\" - ").zhex(Word.objectToUntrackedPointer(threadObj));
687+
if (threadObj.isDaemon()) {
688+
log.string(", daemon");
689+
}
686690
}
687691
}
688692
log.string(", stack(").zhex(VMThreads.StackEnd.get(thread)).string(",").zhex(VMThreads.StackBase.get(thread)).string(")");

0 commit comments

Comments
 (0)