Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8307955

Prefer to PTRACE_GETREGSET instead of PTRACE_GETREGS in method 'ps_proc.c::process_get_lwp_regs'

    XMLWordPrintable

Details

    • b23

    Backports

      Description

        As the man page of `ptrace` states [1], `PTRACE_GETREGS and PTRACE_GETFPREGS are not present on all architectures`, we should prefer using `PTRACE_GETREGSET` instead of `PTRACE_GETREGS` when invoking the method 'ptrace'.

        The code of `ps_proc.c::process_get_lwp_regs` [2] try to use `PTRACE_GETREGS` first, and `PTRACE_GETREGSET` is a second option. It leads the `process_get_lwp_regs` fails at some special ENVs. In my local riscv-linux env, several tests failed.

        The failed test is shown below:
        ```
        serviceability/sa/ClhsdbCDSJstackPrintAll.java
        serviceability/sa/ClhsdbDumpheap.java
        serviceability/sa/ClhsdbFindPC.java#no-xcomp-process
        serviceability/sa/ClhsdbJdis.java
        serviceability/sa/ClhsdbJstack.java#id1
        serviceability/sa/ClhsdbPrintAs.java
        serviceability/sa/ClhsdbSource.java
        serviceability/sa/ClhsdbThreadContext.java
        serviceability/sa/ClhsdbWhere.java
        serviceability/sa/TestClhsdbJstackLock.java
        serviceability/sa/TestJhsdbJstackLock.java
        ```

        The log of the failed test `serviceability/sa/ClhsdbCDSJstackPrintAll.java`:
        ```
        java.lang.RuntimeException: Test ERROR java.lang.RuntimeException: 'LingeredApp.steadyState' missing from stdout/stderr
        at ClhsdbCDSJstackPrintAll.main(ClhsdbCDSJstackPrintAll.java:117)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:578)
        at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:125)
        at java.base/java.lang.Thread.run(Thread.java:1583)
        Caused by: java.lang.RuntimeException: 'LingeredApp.steadyState' missing from stdout/stderr
        at jdk.test.lib.process.OutputAnalyzer.shouldMatch(OutputAnalyzer.java:340)
        at ClhsdbLauncher.runCmd(ClhsdbLauncher.java:166)
        at ClhsdbLauncher.run(ClhsdbLauncher.java:203)
        at ClhsdbCDSJstackPrintAll.main(ClhsdbCDSJstackPrintAll.java:113)
        ... 4 more

        JavaTest Message: Test threw exception: java.lang.RuntimeException: Test ERROR java.lang.RuntimeException: 'LingeredApp.steadyState' missing from stdout/stderr
        ```

        [1] https://man7.org/linux/man-pages/man2/ptrace.2.html
        [2] https://github.com/openjdk/jdk/blob/5d6cce0f8543e8ae966798aad685b190cc8101aa/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c#L148

        Attachments

          Issue Links

            Activity

              People

                gli Guoxiong Li
                gli Guoxiong Li
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: