adoptium / aqa-tests

Home of test infrastructure for Adoptium builds
https://adoptium.net/aqavit
Apache License 2.0
129 stars 308 forks source link

jdk11 Win32 OnJcmdTest fails : Debugging has not been started: Could not find jdwp agent. #2837

Open andrew-m-leonard opened 3 years ago

andrew-m-leonard commented 3 years ago

Describe the bug Triage of jdk-11.0.12+7 shows a repeatable failure for com/sun/jdi/OnJcmdTest.java https://github.com/adoptium/adoptium/issues/62#issuecomment-907259150 I'm not sure this test has ever passed on Win32 jdk-11.

To Reproduce Steps to reproduce the behavior (or Grinder rerun link): https://ci.adoptopenjdk.net/view/Test_grinder/job/Grinder/1316/console

Rerun in Grinder link

Expected behavior A clear and concise description of what you expected to happen. Test should Pass like all the other platforms, eg.Win64:

Command line: [E:\workspace\Test_openjdk11_hs_extended.openjdk_x86-64_windows_testList_0\openjdkbinary\j2sdk-image\bin\java.exe -cp E:\workspace\Test_openjdk11_hs_extended.openjdk_x86-64_windows_testList_0\aqa-tests\TKG\output_16268620041358\jdk_jdi_1\work\classes\3\com\sun\jdi\OnJcmdTest.d;E:\workspace\Test_openjdk11_hs_extended.openjdk_x86-64_windows_testList_0\aqa-tests\openjdk\openjdk-jdk\test\jdk\com\sun\jdi;E:\workspace\Test_openjdk11_hs_extended.openjdk_x86-64_windows_testList_0\aqa-tests\TKG\output_16268620041358\jdk_jdi_1\work\classes\3\test\lib;E:\workspace\Test_openjdk11_hs_extended.openjdk_x86-64_windows_testList_0\aqa-tests\openjdk\openjdk-jdk\test\lib;E:\workspace\Test_openjdk11_hs_extended.openjdk_x86-64_windows_testList_0\jvmtest\openjdk\jtreg\lib\javatest.jar;E:\workspace\Test_openjdk11_hs_extended.openjdk_x86-64_windows_testList_0\jvmtest\openjdk\jtreg\lib\jtreg.jar -ea -esa -Xmx512m -XX:-UseCompressedOops -agentlib:jdwp=transport=dt_socket,address=any,onjcmd=y ]
Command line: [E:\workspace\Test_openjdk11_hs_extended.openjdk_x86-64_windows_testList_0\openjdkbinary\j2sdk-image\bin\java.exe -cp E:\workspace\Test_openjdk11_hs_extended.openjdk_x86-64_windows_testList_0\aqa-tests\TKG\output_16268620041358\jdk_jdi_1\work\classes\3\com\sun\jdi\OnJcmdTest.d;E:\workspace\Test_openjdk11_hs_extended.openjdk_x86-64_windows_testList_0\aqa-tests\openjdk\openjdk-jdk\test\jdk\com\sun\jdi;E:\workspace\Test_openjdk11_hs_extended.openjdk_x86-64_windows_testList_0\aqa-tests\TKG\output_16268620041358\jdk_jdi_1\work\classes\3\test\lib;E:\workspace\Test_openjdk11_hs_extended.openjdk_x86-64_windows_testList_0\aqa-tests\openjdk\openjdk-jdk\test\lib;E:\workspace\Test_openjdk11_hs_extended.openjdk_x86-64_windows_testList_0\jvmtest\openjdk\jtreg\lib\javatest.jar;E:\workspace\Test_openjdk11_hs_extended.openjdk_x86-64_windows_testList_0\jvmtest\openjdk\jtreg\lib\jtreg.jar -ea -esa -Xmx512m -XX:-UseCompressedOops -agentlib:jdwp=transport=dt_socket,address=any,onjcmd=y,onthrow=a,launch=a ]
Listening for transport dt_socket at address: 62168
andrew-m-leonard commented 3 years ago

This code fails to load jdwp: https://github.com/adoptium/jdk11u/blob/1752c3afb115e1bf689229b56eedad5701ecc069/src/hotspot/share/services/diagnosticCommand.cpp#L1082

andrew-m-leonard commented 3 years ago

To recreate standalone with Win32 JDK: Create a OnJcmdTest.java:

class OnJcmdTest {
    public static void main(String[] args) {
        try {
          System.out.println("OnJcmdTest: sleeping 200 seconds  ...");
          Thread.sleep(200000);
          System.out.println("Finished!");
        } catch(Exception e) {
          e.printStackTrace();
        }
    }
}

Start it with:

start java --add-exports java.base/jdk.internal.vm=ALL-UNNAMED -agentlib:jdwp=transport=dt_socket,address=localhost:0,onjcmd=y,server=y OnJcmdTest

Find its "process id" from Task Manager

Then run:

jcmd <process_id> VM.start_java_debugging
andrew-m-leonard commented 3 years ago

I think this is an upstream bug, I believe this line that gets called to resolve the OnJcmd jdwp.dll entry fails on Win32 https://github.com/adoptium/jdk11u/blob/815d3e1c6cd8272f962eaec80758cafa97c1dda5/src/hotspot/share/runtime/os.cpp#L591 It calls GetProcAddress, on Windows which I guess may not work the same as Win64

it's called from here as part of the DebugOnCmdStartDCmd flow: https://github.com/adoptium/jdk11u/blob/815d3e1c6cd8272f962eaec80758cafa97c1dda5/src/hotspot/share/services/diagnosticCommand.cpp#L1098

sophia-guo commented 3 years ago

Same for jdk16+. Will exclude it.