Skip to content

8378985: serviceability/sa/TestJhsdbJstackMixedWithXComp.java failed if sender frame is return barrier of Continuation#30107

Closed
YaSuenag wants to merge 10 commits intoopenjdk:masterfrom
YaSuenag:JDK-8378985
Closed

8378985: serviceability/sa/TestJhsdbJstackMixedWithXComp.java failed if sender frame is return barrier of Continuation#30107
YaSuenag wants to merge 10 commits intoopenjdk:masterfrom
YaSuenag:JDK-8378985

Conversation

@YaSuenag
Copy link
Copy Markdown
Member

@YaSuenag YaSuenag commented Mar 6, 2026

We saw the failure in serviceability/sa/TestJhsdbJstackMixedWithXComp.java on Valhalla repo. jhsdb jstack --mixed could not unwind continuation call frames as following:

                   * LingeredAppWithVirtualThread.run() bci:15 line:69 (Interpreted frame)
                   * java.lang.Thread.runWith(java.lang.Object, java.lang.Runnable) bci:5 line:1540 (Compiled frame [deoptimized]; information may be imprecise)
                   * java.lang.VirtualThread.run(java.lang.Runnable) bci:62 line:472 (Compiled frame [deoptimized]; information may be imprecise)
0x00007fdad773cf98 <StubRoutines (continuation stubs)>
0xfefefefefefefefe ????????

I found that frame::sender_for_compiled_frame() in frame_x86.inline.hpp has a special case if sender PC has return barrier entry, but SA does not handle it.

This is not only a problem on Valhalla. Same problem exists on JDK. So I want to fix on JDK.
This PR passed serviceability/sa tests on Linux, and also TestJhsdbJstackMixedWithXComp.java on Valhalla passed 100 times.

This PR is assembled by following commits:

  • Follows continuation-related code in HotSpot, and use it on AMD64 SA code
  • Fix for AArch64
  • Fix for RISC-V
  • Fix for PPC64

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8378985: serviceability/sa/TestJhsdbJstackMixedWithXComp.java failed if sender frame is return barrier of Continuation (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/30107/head:pull/30107
$ git checkout pull/30107

Update a local copy of the PR:
$ git checkout pull/30107
$ git pull https://git.openjdk.org/jdk.git pull/30107/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 30107

View PR using the GUI difftool:
$ git pr show -t 30107

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/30107.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper bot commented Mar 6, 2026

👋 Welcome back ysuenaga! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link
Copy Markdown

openjdk bot commented Mar 6, 2026

@YaSuenag This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8378985: serviceability/sa/TestJhsdbJstackMixedWithXComp.java failed if sender frame is return barrier of Continuation

Reviewed-by: cjplummer, mdoerr, fyang

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 271 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added serviceability serviceability-dev@openjdk.org hotspot-runtime hotspot-runtime-dev@openjdk.org labels Mar 6, 2026
@openjdk
Copy link
Copy Markdown

openjdk bot commented Mar 6, 2026

@YaSuenag The following labels will be automatically applied to this pull request:

  • hotspot-runtime
  • serviceability

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@YaSuenag YaSuenag marked this pull request as ready for review March 6, 2026 09:41
@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 6, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge bot commented Mar 6, 2026

Webrevs

@YaSuenag
Copy link
Copy Markdown
Member Author

YaSuenag commented Mar 6, 2026

Could someone can help for testing on RISC-V and PPC64?

This PR includes changes for them. It affects serviceability/sa tests especially TestJhsdbJstackWithVirtualThread.java. I tested both AMD64 and AArch64 Linux, but I cannot test RISC-V and PPC64 because I do not have them.

Copy link
Copy Markdown
Contributor

@plummercj plummercj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good and passes my testing. I can only test that it builds on riscv64. I can't run tests on that platform, and can't do builds or testing on s390 or PPC.

public abstract Address getFP();

public void setSP(Address newSP) {
throw new UnsupportedPlatformException("Continuation is not yet implemented.");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I understand that this method is not overridden on platforms that don't support continuations (s390), the relationship between a method with a generic name like "setSP" and a specific error messages about continuations is not obvious. If setSP() only only useful in the context of continuations, I'd suggest naming it something like setContinuationSP(), or you can leave it as setSP() but get rid of the reference to continuations in the error message.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can make it to abstract method, so I did it in new commit.

Comment on lines +39 to +41
public static boolean isSPInContinuation(ContinuationEntry entry, Address sp) {
return entry.getEntrySP().greaterThan(sp);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be made private.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is public member in HotSpot, so I aligned with it. However it does not need to be public in SA.
Should we it to be private?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok to keep public then.

return entry.getEntrySP().greaterThan(sp);
}

public static ContinuationEntry getContinuationEntryForSP(JavaThread thread, Address sp) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also could be made private.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is public member in HotSpot, so I aligned with it. However it does not need to be public in SA.
Should we it to be private?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok to keep public then.

Comment on lines +266 to +282
// HotSpot has following code in frame::sender_raw() at frame_x86.inline.hpp, however
// in_cont() should be false.
//
// if (map->in_cont()) { // already in an h-stack
// return map->stack_chunk()->sender(*this, map);
// }
//
// in_cont() returns true if _chunk() is not null.
//
// frame::next_frame() creates RegisterMap instance with 4 arguments.
// It sets RegisterMap::WalkContinuation::skip to final argument (walk_count),
// then _chunk would not be initialized following code in c'tor of RegisterMap.
//
// if (walk_cont == WalkContinuation::include && thread != nullptr && thread->last_continuation() != nullptr) {
// _chunk = stackChunkHandle(Thread::current()->handle_area()->allocate_null_handle(), true /* dummy */);
// }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how this comment is relevant to the code below. Why is this here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SA should follow HotSpot implementation, so that code should be included basically. However it is not needed in this case. Thus I left comment the reason.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't follow. Are you saying that map->in_cont() will always return true so you don't need the walk_cont related code?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just want to say we don't need to copy return map->stack_chunk()->sender(*this, map) to SA from HotSpot because map->in_cont() should be false in use case of SA.

in_cont() returns true if _chunk is not NULL, but it would not happen in the use case of SA because RegisterMap would not be initialized with WalkContinuation::include.

@YaSuenag
Copy link
Copy Markdown
Member Author

YaSuenag commented Mar 7, 2026

can't do builds or testing on s390 or PPC.

We do not need to consider s390 because SA does not have s390 implementation.

return senderForUpcallStub(map, (UpcallStub)cb);
} else if (cb.isContinuationStub()) {
return senderForContinuationStub(map, cb);
} else {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
I tried this on linux-riscv64 platform and I witnessed test failure when running serviceability/sa/TestJhsdbJstackWithVirtualThread.java:

java.lang.RuntimeException: 'must have non-zero frame size' found in stdout
        at jdk.test.lib.process.OutputAnalyzer.shouldNotContain(OutputAnalyzer.java:299)
        at TestJhsdbJstackWithVirtualThread.runJstack(TestJhsdbJstackWithVirtualThread.java:63)
        at TestJhsdbJstackWithVirtualThread.main(TestJhsdbJstackWithVirtualThread.java:74)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:565)
        at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:335)
        at java.base/java.lang.Thread.run(Thread.java:1527)

JavaTest Message: Test threw exception: java.lang.RuntimeException
JavaTest Message: shutting down test

I guess you might want to add following add-on change. I see aarch64 and amd64 has a similar frame size check before invoking senderForCompiledFrame method.

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 67b4314a3c7..a35c0735979 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
@@ -269,7 +269,7 @@ public Frame sender(RegisterMap regMap, CodeBlob cb) {
     if (cb != null) {
       if (cb.isUpcallStub()) {
         return senderForUpcallStub(map, (UpcallStub)cb);
-      } else {
+      } else if (cb.getFrameSize() > 0) {
         return senderForCompiledFrame(map, cb);
       }
     }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! You are right.
I applied that change to both RISC-V and PPC64. Could you check again?

Copy link
Copy Markdown
Member

@RealFYang RealFYang Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My local hotspot_serviceability and jdk_svc tests on linux-riscv64 are passing using the latest version. Thanks for the update.

@dholmes-ora
Copy link
Copy Markdown
Member

Just a drive-by comment, but if this is being fixed in mainline then the [lworld] should be removed from the JBS title. Though IIUC no failure has been seen in mainline - is that correct?

@YaSuenag YaSuenag changed the title 8378985: [lworld] serviceability/sa/TestJhsdbJstackMixedWithXComp.java#xcomp fails with just Test failed! 8378985: serviceability/sa/TestJhsdbJstackMixedWithXComp.java failed if sender frame is return barrier of Continuation Mar 9, 2026
@YaSuenag
Copy link
Copy Markdown
Member Author

YaSuenag commented Mar 9, 2026

Fixed title both this PR and JBS.

Though IIUC no failure has been seen in mainline - is that correct?

Yes, however mainline has potential bug, so I want to fix mainline first.
I'm not sure, but this bug may be more likely to occur in Valhalla than in the mainline.

@TheRealMDoerr
Copy link
Copy Markdown
Contributor

Could someone can help for testing on RISC-V and PPC64?

This PR includes changes for them. It affects serviceability/sa tests especially TestJhsdbJstackWithVirtualThread.java. I tested both AMD64 and AArch64 Linux, but I cannot test RISC-V and PPC64 because I do not have them.

Tier1-4 have passed on PPC64. Thanks for implementing it for all SA platforms!

Comment thread src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/amd64/AMD64Frame.java Outdated
Comment thread src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/amd64/AMD64Frame.java Outdated
YaSuenag and others added 2 commits March 10, 2026 13:01
…d64/AMD64Frame.java

Co-authored-by: Chris Plummer <chris.plummer@oracle.com>
…d64/AMD64Frame.java

Co-authored-by: Chris Plummer <chris.plummer@oracle.com>
@YaSuenag
Copy link
Copy Markdown
Member Author

PING: Can I get Reviewers? This PR has passed SA tests on all of supported platforms.

Copy link
Copy Markdown
Contributor

@TheRealMDoerr TheRealMDoerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PPC64 code looks correct to me. Thanks!

// We assume WalkContinuation is "WalkContinuation::skip".
// It is same with c'tor arguments of RegisterMap in frame::next_frame().
//
// HotSpot code in cpu/riscv/frame_riscv.inline.hpp:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should better refer to cpu/ppc/frame_ppc.inline.hpp

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Fixed it in new commit.


@Override
public Frame toFrame() {
return new AARCH64Frame(getEntrySP(), getEntrySP(), getEntryFP(), getEntryPC());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the same code replicated for all platforms? (May make senes. Not sure.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This structure comes from HotSpot.
to_frame() is defined in continuationEntry_<arch>.inline.hpp. So I think it is better to follow it because most of source file in SA follows HotSpot manner.

Copy link
Copy Markdown
Contributor

@TheRealMDoerr TheRealMDoerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PPC64 parts looks good. Only a partial review. Thanks!

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 23, 2026
Copy link
Copy Markdown
Contributor

@plummercj plummercj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Copy link
Copy Markdown
Member

@RealFYang RealFYang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RISC-V part of the change looks fine. hotspot_serviceability and jdk_svc still test good on this platform.

@YaSuenag
Copy link
Copy Markdown
Member Author

/integrate

@openjdk
Copy link
Copy Markdown

openjdk bot commented Mar 26, 2026

Going to push as commit 69deec2.
Since your change was applied there have been 293 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Mar 26, 2026
@openjdk openjdk bot closed this Mar 26, 2026
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Mar 26, 2026
@openjdk
Copy link
Copy Markdown

openjdk bot commented Mar 26, 2026

@YaSuenag Pushed as commit 69deec2.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@YaSuenag YaSuenag deleted the JDK-8378985 branch March 26, 2026 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

5 participants