adoptium / temurin-build

Eclipse Temurin™ build scripts - common across all releases/versions
Apache License 2.0
1.03k stars 249 forks source link

nightly jdk11 Win32 jshell error #709

Closed tico-tico closed 5 years ago

tico-tico commented 6 years ago

I'm not sure whether it's a known issue or not. Tried nightly 01-11-2018 on Windows 7 Home, SP1, 32-bit.

C:\Program Files\jdk-11\bin>jshell
Launching JShell execution engine threw: ERROR: transport library missing onLoad entry: dt_socket
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_LOAD(509)
JDWP exit error AGENT_ERROR_TRANSPORT_LOAD(196): No transports initialized [:732]
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_LOAD(196)
karianna commented 6 years ago

Do javac and java run OK?

karianna commented 6 years ago

Also are dt_socket.dll and dt_shmem.dll in the $JAVA_HOME/bin/ directory or anywhere else on your PC?

tico-tico commented 6 years ago

Do javac and java run OK?

Yes, i should have mentioned it, sorry.

Also are dt_socket.dll and dt_shmem.dll in the $JAVA_HOME/bin/ directory or anywhere else on your PC?

Yes, they are in bin, 32-bit dlls.

karianna commented 6 years ago

@ali-ince I'll pass this over to you if that's OK - would be interested to know if you have the same error locally

ali-ince commented 6 years ago

I can reproduce the issue on my local computer as well. It seems it's related with exported symbol names on dll's, that's the main difference on 32-bit and 64-bit dt_socket.dll.

I'll try to figure out what causes this difference.

tico-tico commented 6 years ago

I can reproduce the issue on my local computer as well. It seems it's related with exported symbol names on dll's, that's the main difference on 32-bit and 64-bit dt_socket.dll.

I'll try to figure out what causes this difference.

Yep, just for fun I using hex-editor changed jdwpTransport_OnLoad to _jdwpTransport_OnLoad@16 in jdwp.dll and now jshell runs OK.

karianna commented 6 years ago

I can reproduce the issue on my local computer as well. It seems it's related with exported symbol names on dll's, that's the main difference on 32-bit and 64-bit dt_socket.dll. I'll try to figure out what causes this difference.

Yep, just for fun I using hex-editor changed jdwpTransport_OnLoad to _jdwpTransport_OnLoad@16 in jdwp.dll and now jshell runs OK.

Oh, nice find!

tico-tico commented 5 years ago

OK, i did some reading. It turns out that C-function names are decorated by VS only for x86 and not for x64, thats why we have the issue. See here https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/x7kb4e2f(v%3dvs.110) .

Simplest workaround is to patch openjdk-jdk11/src/jdk.jdwp.agent/share/native/libjdwp/transport.c

*** transport-orig.c    2018-11-12 17:01:23.154284000 +0300
--- transport.c 2018-11-12 17:00:17.630930200 +0300
*************** findTransportOnLoad(void *handle)
*** 96,102 ****
--- 96,106 ----
          return onLoad;
      }
      onLoad = (jdwpTransport_OnLoad_t)
+ #if defined(_MSC_VER) && defined(_M_IX86)
+                  dbgsysFindLibraryEntry(handle, "_jdwpTransport_OnLoad@16");
+ #else
                   dbgsysFindLibraryEntry(handle, "jdwpTransport_OnLoad");
+ #endif
      return onLoad;
  }

Sorry, i can't test it myself, consider it as a hint.

karianna commented 5 years ago

@ali-ince If you're able to lest this then I think we can submit a patch upstream.

ali-ince commented 5 years ago

@tico-tico, @karianna I've created a PR for JDK11 which doesn't change the source code but fixes the exported function name to be jdwpTransport_OnLoad.

ali-ince commented 5 years ago

sorry for getting back to this late.

@karianna the upstream patch has already been merged into jdk 13 (https://bugs.openjdk.java.net/browse/JDK-8214122). Similar to #763, could you please point me in the right direction to get a backport into jdk12/11?

karianna commented 5 years ago

@ali-ince Looks like Christopher Langer is backporting to 11u - https://bugs.openjdk.java.net/browse/JDK-8214122 - if you comment on the jdk-updates mailing list at OpenJDK, reference this issue number and ask Christopher if he'll also backport to 12 (and offer to do so if he doesn't) then that should get this through - thanks!

ali-ince commented 5 years ago

This is already fixed in upstream jdk11u and now it’s also applied into jdk12u which will be included in a later release as well.

I’ve created a revert PR of our initial fix as well.

Closing this issue.

MagicZer0 commented 3 years ago

hello, the same problem has occured on my Mac:

➜  ~ jshell
Launching JShell execution engine threw: ERROR: transport error 202: handshake failed - connection prematurally closed
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [./open/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c:732]

tested env:

jdk 11.0.9
macos 10.15.7
aahlenst commented 3 years ago

@MagicZer0 That problem happened on Windows. macOS is a different beast. Please open a new ticket https://github.com/adoptopenjdk/openjdk-support and provide additional details. I tried to launch jshell from 11.0.9 and it's working for me.