test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackWithVirtualThread.java 
checks whether `jhsdb jstack` for VirtualThread works, and it seems to pass so 
far. However .jtr file includes following lines. It would not trigger the test 
failure.


"ForkJoinPool-1-worker-1" #24 daemon prio=5 tid=0x00007f9b0c4fb3e0 nid=91489 
runnable [0x00007f9af18ff000]
   java.lang.Thread.State: RUNNABLE
   JavaThread state: _thread_in_native
 - java.lang.invoke.LambdaForm$MH+0x0000000070047800.invoke(java.lang.Object, 
long, int) @bci=10 (Interpreted frame)
 - 
java.lang.invoke.LambdaForm$MH+0x000000007004d400.invokeExact_MT(java.lang.Object,
 long, int, java.lang.Object) @bci=21 (Interpreted frame)
 - 
jdk.internal.foreign.abi.DowncallStub+0x0000000070048800.invoke(java.lang.foreign.SegmentAllocator,
 java.lang.foreign.MemorySegment, int) @bci=44 (Interpreted frame)
 - 
java.lang.invoke.LambdaForm$DMH+0x0000000070048c00.invokeStaticInit(java.lang.Object,
 java.lang.Object, java.lang.Object, int) @bci=14 (Interpreted frame)
 - java.lang.invoke.LambdaForm$MH+0x000000007004c800.invoke(java.lang.Object, 
int) @bci=44 (Interpreted frame)
 - 
java.lang.invoke.LambdaForm$MH+0x000000007004c400.invoke_MT(java.lang.Object, 
int, java.lang.Object) @bci=18 (Interpreted frame)
 - LingeredAppWithVirtualThread.run() @bci=15, line=69 (Interpreted frame)

Error occurred during stack walking:
sun.jvm.hotspot.debugger.UnalignedAddressException: Trying to read at address: 
0x000000000000000d with alignment: 8
at 
jdk.hotspot.agent/sun.jvm.hotspot.debugger.DebuggerUtilities.checkAlignment(DebuggerUtilities.java:68)
at 
jdk.hotspot.agent/sun.jvm.hotspot.debugger.DebuggerBase.readCInteger(DebuggerBase.java:352)
at 
jdk.hotspot.agent/sun.jvm.hotspot.debugger.DebuggerBase.readAddressValue(DebuggerBase.java:385)
at 
jdk.hotspot.agent/sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.readAddress(LinuxDebuggerLocal.java:493)
at 
jdk.hotspot.agent/sun.jvm.hotspot.debugger.linux.LinuxAddress.getAddressAt(LinuxAddress.java:73)
at 
jdk.hotspot.agent/sun.jvm.hotspot.runtime.amd64.AMD64Frame.getLink(AMD64Frame.java:453)
at 
jdk.hotspot.agent/sun.jvm.hotspot.runtime.amd64.AMD64Frame.sender(AMD64Frame.java:304)
at jdk.hotspot.agent/sun.jvm.hotspot.runtime.Frame.sender(Frame.java:218)
at jdk.hotspot.agent/sun.jvm.hotspot.runtime.Frame.realSender(Frame.java:223)
at jdk.hotspot.agent/sun.jvm.hotspot.runtime.VFrame.sender(VFrame.java:120)
at jdk.hotspot.agent/sun.jvm.hotspot.runtime.VFrame.javaSender(VFrame.java:150)
at jdk.hotspot.agent/sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:81)
at jdk.hotspot.agent/sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45)
at jdk.hotspot.agent/sun.jvm.hotspot.tools.JStack.run(JStack.java:67)
at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.startInternal(Tool.java:278)
at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.start(Tool.java:241)
at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.execute(Tool.java:134)
at jdk.hotspot.agent/sun.jvm.hotspot.tools.JStack.runWithArgs(JStack.java:90)
at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.runJSTACK(SALauncher.java:306)
at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.main(SALauncher.java:507)


It is caused that frame implementation in SA such as `AMD64Frame` cannot handle 
continuation in `senderForInterpreterFrame()`. For compiled frame, it has been 
fixed in [JDK-8378985](https://bugs.openjdk.org/browse/JDK-8378985). Same code 
is needed for interpreted frame.

This PR is for AMD64 and AArch64 only. I guess there are same problem in other 
platforms (PPC64 and RISC-V), but this PR does not contain the fix for them 
because I cannot evaluate the problem and the fix.

---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

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

Commit messages:
 - Handle Continuation in stack unwinding from interpreted frame

Changes: https://git.openjdk.org/jdk/pull/33656/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=33656&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8396232
  Stats: 38 lines in 2 files changed: 36 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/33656.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/33656/head:pull/33656

PR: https://git.openjdk.org/jdk/pull/33656

Reply via email to