RFR: 8369505: jhsdb jstack --mixed cannot handle continuation stub on Linux

Fei Yang fyang at openjdk.org
Mon Oct 13 02:12:05 UTC 2025


On Sat, 11 Oct 2025 14:54:05 GMT, Yasumasa Suenaga <ysuenaga at openjdk.org> wrote:

>>> I applied the changes to AARCH64Frame.java and they seem to fix the issue with the exception. I'm seeing two different stack traces (see below), and neither is identical to your fixed stack trace. I don't see `<StubRoutines (continuation stubs)>`. Instead I see a frame for `jdk.internal.vm.Continuation.enterSpecial()`. Also, I don't see `<StubRoutines (initial stubs)>` or any of the frames that come after it. Maybe these are just expected platform differences.
>>>
>> These two different stack traces are expected and depend on whether the vthread was unmounted or not. With the current test this is timing dependent. You can run the test commenting out the `System.out.println` call, and then again replacing it with `Thread.yield()`. The string `<StubRoutines (continuation stubs)>` does look like from a previous version though. Even on x64 I see the `enterSpecial` frame printed out, and it matches what I would expect based on the patch.
>
> @pchilano I reproduce the problem with `Thread.yield()`. Thanks! So I added test in the latest commit. I believe it works on both AMD64 and AArch64.

@YaSuenag : 
Hi, I tried on linux-riscv64 and I see the assertion failure is triggering on this platform as well.
Seems that your changes are applicable to riscv64 with minor tweak. Maybe you can add this? Thanks.


diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/riscv64/RISCV64Frame.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/riscv64/RISCV64Frame.java
index e02e056f028..44c8f4c679c 100644
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/riscv64/RISCV64Frame.java
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/riscv64/RISCV64Frame.java
@@ -262,7 +262,13 @@ public Frame sender(RegisterMap regMap, CodeBlob cb) {
     }

     if (cb != null) {
-      return cb.isUpcallStub() ? senderForUpcallStub(map, (UpcallStub)cb) : senderForCompiledFrame(map, cb);
+      if (cb.isUpcallStub()) {
+        return senderForUpcallStub(map, (UpcallStub)cb);
+      } else if (cb.isContinuationStub()) {
+        return senderForContinuationStub(map, cb);
+      } else {
+        return senderForCompiledFrame(map, cb);
+      }
     }

     // Must be native-compiled frame, i.e. the marshaling code for native
@@ -348,6 +354,16 @@ private void updateMapWithSavedLink(RegisterMap map, Address savedFPAddr) {
     map.setLocation(fp, savedFPAddr);
   }

+  private Frame senderForContinuationStub(RISCV64RegisterMap map, CodeBlob cb) {
+    var contEntry = map.getThread().getContEntry();
+
+    Address senderSP = contEntry.getEntrySP();
+    Address senderPC = contEntry.getEntryPC();
+    Address senderFP = contEntry.getEntryFP();
+
+    return new RISCV64Frame(senderSP, senderFP, senderPC);
+  }
+
   private Frame senderForCompiledFrame(RISCV64RegisterMap map, CodeBlob cb) {
     if (DEBUG) {
       System.out.println("senderForCompiledFrame");
diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedWithVirtualThread.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedWithVirtualThread.java
index 2565fdf9056..9b4fa067dc0 100644
--- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedWithVirtualThread.java
+++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedWithVirtualThread.java
@@ -37,7 +37,7 @@
  * @test
  * @bug 8369505
  * @requires (os.family == "linux") & (vm.hasSA)
- * @requires (os.arch == "amd64" | os.arch == "aarch64")
+ * @requires (os.arch == "amd64" | os.arch == "aarch64" | os.arch == "riscv64")
  * @library /test/lib
  * @run driver TestJhsdbJstackMixedWithVirtualThread
  */

-------------

PR Comment: https://git.openjdk.org/jdk/pull/27728#issuecomment-3395643581


More information about the serviceability-dev mailing list