-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8370176: Mixed mode jhsdb jstack cannot unwind call stack with -Xcomp #27885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
58668e6
39274ff
9d02325
a75aa29
3f7697f
0e7c4cc
434e8d2
ff070a3
b08101b
082ee46
0ba1e48
879cf19
16a9a20
3e0bfd0
ec5d0e2
eb2f0ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| /* | ||
| * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. | ||
| * Copyright (c) 2025, NTT DATA | ||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| * | ||
| * This code is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU General Public License version 2 only, as | ||
| * published by the Free Software Foundation. | ||
| * | ||
| * This code is distributed in the hope that it will be useful, but WITHOUT | ||
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| * version 2 for more details (a copy is included in the LICENSE file that | ||
| * accompanied this code). | ||
| * | ||
| * You should have received a copy of the GNU General Public License version | ||
| * 2 along with this work; if not, write to the Free Software Foundation, | ||
| * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| * | ||
| * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| * or visit www.oracle.com if you need additional information or have any | ||
| * questions. | ||
| */ | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.regex.Matcher; | ||
| import java.util.regex.Pattern; | ||
|
|
||
| import jdk.test.lib.JDKToolLauncher; | ||
| import jdk.test.lib.SA.SATestUtils; | ||
| import jdk.test.lib.Utils; | ||
| import jdk.test.lib.apps.LingeredApp; | ||
| import jdk.test.lib.process.OutputAnalyzer; | ||
|
|
||
| /** | ||
| * @test | ||
| * @bug 8370176 | ||
| * @requires vm.hasSA | ||
| * @requires os.family == "linux" | ||
| * @requires (os.arch == "amd64" | os.arch == "aarch64") | ||
| * @library /test/lib | ||
| * @run driver TestJhsdbJstackMixedWithXComp | ||
| */ | ||
| public class TestJhsdbJstackMixedWithXComp { | ||
|
|
||
| private static void runJstack(LingeredApp app) throws Exception { | ||
| JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb"); | ||
| launcher.addVMArgs(Utils.getFilteredTestJavaOpts("-showversion")); | ||
| launcher.addToolArg("jstack"); | ||
| launcher.addToolArg("--mixed"); | ||
| launcher.addToolArg("--pid"); | ||
| launcher.addToolArg(Long.toString(app.getPid())); | ||
|
|
||
| ProcessBuilder pb = SATestUtils.createProcessBuilder(launcher); | ||
| Process jhsdb = pb.start(); | ||
| OutputAnalyzer out = new OutputAnalyzer(jhsdb); | ||
|
|
||
| jhsdb.waitFor(); | ||
|
|
||
| String stdout = out.getStdout(); | ||
| System.out.println(stdout); | ||
| System.err.println(out.getStderr()); | ||
|
|
||
| out.stderrShouldBeEmptyIgnoreDeprecatedWarnings(); | ||
|
||
|
|
||
| List<String> targetStackTrace = new ArrayList<>(); | ||
| boolean inStack = false; | ||
| System.out.println("DEBUG: before loop"); | ||
| for (String line : stdout.split("\n")) { | ||
| if (line.contains("<nep_invoker_blob>")) { | ||
| inStack = true; | ||
| System.out.println("DEBUG: IN"); | ||
| } else if (inStack && line.contains("-----------------")) { | ||
| inStack = false; | ||
| System.out.println("DEBUG: OUT"); | ||
| break; | ||
| } | ||
|
|
||
| if (inStack) { | ||
| System.out.println("DEBUG: " + line); | ||
| targetStackTrace.add(line); | ||
| } | ||
| } | ||
| System.out.println("DEBUG: after loop"); | ||
|
|
||
| boolean found = targetStackTrace.stream() | ||
| .anyMatch(l -> l.contains("thread_native_entry")); | ||
| if (!found) { | ||
| throw new RuntimeException("Test failed!"); | ||
| } | ||
| } | ||
|
|
||
| public static void main(String... args) throws Exception { | ||
| SATestUtils.skipIfCannotAttach(); // throws SkippedException if attach not expected to work. | ||
| LingeredApp app = null; | ||
|
|
||
| try { | ||
| app = new LingeredAppWithVirtualThread(); | ||
| LingeredApp.startApp(app, "-Xcomp"); | ||
| System.out.println("Started LingeredApp with pid " + app.getPid()); | ||
| runJstack(app); | ||
| System.out.println("Test Completed"); | ||
| } catch (Throwable e) { | ||
| e.printStackTrace(); | ||
| throw e; | ||
| } finally { | ||
| LingeredApp.stopApp(app); | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do Windows and OSX have a similar problem that should be fixed also?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This problem is in mixed mode (
PStack) only, thus we need to skip OSX because you mentioned mixed mode is not supported on OSX.In Windows, I'm not sure, but I guess we need to consider
UNWIND_INFOto unwind call frames correctly like DWARF in Linux, however it hasn't done yet. Thus we can think mixed mode is not supported in Windows too, so I didn't add Windows here.https://learn.microsoft.com/cpp/build/exception-handling-x64
Actually I could not see all of stacks as following in mixed mode. It works in normal mode (without
--mixed) of course. (I tested it on Windows 11 x64, upstream JDK built by VS 2022)Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind you that this new test seems to fail even on linux systems without pstack. This is happening on both of my AMD64 machine running Debian 12 and ARM64 machine running Ubuntu 22.04.4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you share .jtr file?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. This is what I got on my amd64 machine:
$ make test TEST="serviceability/sa/TestJhsdbJstackMixedWithXComp.java"TestJhsdbJstackMixedWithXComp.jtr.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated this PR to check glibc version in TestJhsdbJstackMixedWithXComp.java added by this PR. It skips the test on Ubuntu 22.04, OTOH it works on Fedora 43. It is expected.
I attempted to add this check to
SATestUtilsat first, but it seems to be difficult because native access have to be allowed all ofSATestUtilsusers - the impact is too significant.I will file another issue to apply this check to other tests of
jhsdb jstack --mixeduser after this PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated testcase again. It is more scalable for other mixed jstack tests. It works fine on both Fedora 43 and Ubuntu 22.04 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still fails on other distros like Debian 13 on AMD64. It has glibc version 2.41. Attached please fine the JTR file.
TestJhsdbJstackMixedWithXComp.jtr.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RealFYang Thanks a lot for sharing JTR file!
I could find out the problem, and I fixed. We need to handle
RSPmore carefully when parsing DWARF. This PR works fine on Fedora 43 and Ubuntu 22. I believe it works on your Debian/Ubuntu.But I think the failure what you saw on AArch64 is caused by problem(s) on stack unwinder for Linux AArch64, it is different from AMD64. Currently DWARF is supported on Linux AMD64 only, other platforms would attempt to unwind relies on base pointer. It is traditional, but it might not work on DWARF based binaries. I saw DWARF is contained in AArch64 binary in Fedora Rawhide for AArch64 at least. So the test added by this PR might not work on other platforms includes AArch64, RISC-V. Thus I removed them from
@requiresin the test. I think we can enable them if the unwinder (e.g. LinuxAARCH64CFrame.java) supports DWARF, but it is not a scope of this bug.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the latest version now works on my Debian 13 AMD64 machine. Thanks for finding it out. It's good to know the difference.