diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/locks/VMMutex.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/locks/VMMutex.java index 09fa86da8396..7146afe092d0 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/locks/VMMutex.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/locks/VMMutex.java @@ -24,7 +24,6 @@ */ package com.oracle.svm.core.locks; -import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; @@ -35,6 +34,8 @@ import com.oracle.svm.core.c.CIsolateDataFactory; import com.oracle.svm.core.util.VMError; +import jdk.graal.compiler.word.Word; + /** * A mutex that has minimal requirements on Java code. The implementation does not perform memory * allocation, exception unwinding, or other complicated operations. This allows it to be used in @@ -56,6 +57,7 @@ public class VMMutex extends VMLockingPrimitive { private final String name; IsolateThread owner; + @Deprecated @Platforms(Platform.HOSTED_ONLY.class) public VMMutex() { this.name = CIsolateDataFactory.getUnspecifiedSuffix(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/stack/JavaStackWalker.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/stack/JavaStackWalker.java index 5ded8d3e1136..33629cd2aaa8 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/stack/JavaStackWalker.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/stack/JavaStackWalker.java @@ -26,8 +26,6 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; -import com.oracle.svm.core.deopt.DeoptimizationSlotPacking; -import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; @@ -46,6 +44,7 @@ import com.oracle.svm.core.code.CodeInfoTable; import com.oracle.svm.core.code.UntetheredCodeInfo; import com.oracle.svm.core.config.ConfigurationValues; +import com.oracle.svm.core.deopt.DeoptimizationSlotPacking; import com.oracle.svm.core.deopt.DeoptimizedFrame; import com.oracle.svm.core.deopt.Deoptimizer; import com.oracle.svm.core.heap.RestrictHeapAccess; @@ -61,6 +60,7 @@ import jdk.graal.compiler.api.replacements.Fold; import jdk.graal.compiler.core.common.NumUtil; +import jdk.graal.compiler.word.Word; /** * Provides methods to iterate over the physical Java stack frames of a thread (native stack frames @@ -203,14 +203,24 @@ public static void initializeForContinuation(JavaStackWalk walk, StoredContinuat @Uninterruptible(reason = "Prevent deoptimization of stack frames while in this method.", callerMustBe = true) private static void initializeFromFrameAnchor(JavaStackWalk walk, IsolateThread thread, Pointer endSP) { + assert thread.isNonNull(); assert thread != CurrentIsolate.getCurrentThread() : "Walking the stack without specifying a start SP is only allowed when walking other threads"; + assert VMOperation.isInProgressAtSafepoint() : "Walking the stack of another thread is only safe when that thread is stopped at a safepoint"; JavaFrameAnchor frameAnchor = JavaFrameAnchors.getFrameAnchor(thread); - if (frameAnchor.isNull()) { - /* Threads that do not have a frame anchor at a safepoint are not walkable. */ + if (frameAnchor.isNull() || SafepointBehavior.isCrashedThread(thread)) { + /* + * Threads that do not have a frame anchor at a safepoint are not walkable. This can for + * example happen for attached threads that do not have any Java frames at the moment. + * Threads that are marked as crashed are also not walkable because they may no longer + * have a stack. For such threads, we must not access any data in the frame anchor (as + * it is a stack allocated struct). + */ markAsNotWalkable(walk); } else { - initWalk(walk, thread, frameAnchor.getLastJavaSP(), endSP, frameAnchor.getLastJavaIP(), frameAnchor.getPreviousAnchor()); + Pointer startSP = frameAnchor.getLastJavaSP(); + assert startSP.isNonNull(); + initWalk0(walk, startSP, endSP, frameAnchor.getLastJavaIP(), frameAnchor.getPreviousAnchor()); } }