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

-Xrunjdwp fails on static JDK

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 25
    • 25
    • hotspot
    • None
    • b15

      The jtreg `runtime/6294277/SourceDebugExtension.java` test fails on static JDK due to failing to find/load the jdwp agent library. I extracted the command line from the jtreg test below.

      ```
      static-jdk/bin/java -cp /<snip>/jdk/build/linux-x86_64-server-slowdebug/test-support/jtreg_test_hotspot_jtreg_runtime_6294277_SourceDebugExtension_java/classes/0/runtime/6294277/SourceDebugExtension.d -Xrunjdwp:transport=dt_socket,server=y,suspend=n SourceDebugExtension
      Error occurred during initialization of VM
      Could not find agent library jdwp on the library path, with error: libjdwp.so: cannot open shared object file: No such file or directory
      ```

      The issue is due to reporting error too early when the VM cannot find libjdwp using the JVM_OnLoad symbol. Below are the steps used by JvmtiAgent::convert_xrun_agent to find an agent library:

      1. Try find the (static) builtin agent using JVM_OnLoad_jdwp symbol, with lookup_JVM_OnLoad_entry_point. The symbol name is properly covered with the '_jdwp' for builtin library. However, there is no JVM_OnLoad entry point in libjdwp, hence it fails to find the builtin libjdwp agent. Digging back the history, I found JDK-4921986, which removed JVM_OnLoad for jdwp since JDK 5.

      2. If no builtin agent, try locate the libjdwp.so. On static JDK, it fails to find libjdwp.so and causes the VM to exit immediately with error.

      The failure prevents the VM from trying to find the agent using the Agent_OnLoad symbol, with lookup_Agent_OnLoad_entry_point.

      The leyden/hermetic-java-runtime branch fixed the issue for JvmtiAgent::convert_xrun_agent: https://github.com/openjdk/leyden/blob/d52de3c452a19e789c7f2d29427de7d85d626573/src/hotspot/share/prims/jvmtiAgent.cpp#L356. It changes to not bail out too early if there is no libjdwp.so, so it can try to find the builtin libjdwp using Agent_OnLoad symbol. Commit: https://github.com/openjdk/leyden/commit/2122c03b55f9a27161d47a4c95719ab23b7510fe

      I have a related question to this: should -Xrunjdwp supported on static JDK? Looks like -Xrunjdwp is still commonly used, although -Xrun is deprecated.

            jiangli Jiangli Zhou
            jiangli Jiangli Zhou
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: