Skip to content

Commit b338cb3

Browse files
Support unattached threads in VMError.shouldNotReachHere().
1 parent ad940e9 commit b338cb3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/VMErrorSubstitutions.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,21 @@
2727
import static com.oracle.svm.core.heap.RestrictHeapAccess.Access.NO_ALLOCATION;
2828

2929
import org.graalvm.compiler.nodes.UnreachableNode;
30+
import org.graalvm.nativeimage.CurrentIsolate;
3031
import org.graalvm.nativeimage.ImageSingletons;
32+
import org.graalvm.nativeimage.Isolate;
3133
import org.graalvm.nativeimage.LogHandler;
3234
import org.graalvm.nativeimage.Platforms;
3335
import org.graalvm.nativeimage.c.function.CodePointer;
3436
import org.graalvm.nativeimage.impl.InternalPlatform;
3537

3638
import com.oracle.svm.core.NeverInline;
3739
import com.oracle.svm.core.SubstrateDiagnostics;
40+
import com.oracle.svm.core.SubstrateOptions;
3841
import com.oracle.svm.core.Uninterruptible;
3942
import com.oracle.svm.core.annotate.Substitute;
4043
import com.oracle.svm.core.annotate.TargetClass;
44+
import com.oracle.svm.core.c.function.CEntryPointActions;
4145
import com.oracle.svm.core.heap.RestrictHeapAccess;
4246
import com.oracle.svm.core.log.Log;
4347
import com.oracle.svm.core.snippets.KnownIntrinsics;
@@ -135,6 +139,10 @@ public class VMErrorSubstitutions {
135139
static RuntimeException shouldNotReachHere(CodePointer callerIP, String msg, Throwable ex) {
136140
ThreadStackPrinter.printBacktrace();
137141

142+
if (SubstrateOptions.SpawnIsolates.getValue() && CurrentIsolate.getCurrentThread().isNull()) {
143+
CEntryPointActions.enterAttachThreadFromCrashHandler((Isolate) KnownIntrinsics.heapBase());
144+
}
145+
138146
SafepointBehavior.preventSafepoints();
139147
StackOverflowCheck.singleton().disableStackOverflowChecksForFatalError();
140148

0 commit comments

Comments
 (0)