Bug 234674 - java/openjdk8: cannot connect to JVM to debug
Summary: java/openjdk8: cannot connect to JVM to debug
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: i386 Any
: --- Affects Many People
Assignee: freebsd-java (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-06 23:22 UTC by Michael Osipov
Modified: 2019-02-10 12:43 UTC (History)
7 users (show)

See Also:
bugzilla: maintainer-feedback? (java)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Osipov 2019-01-06 23:22:18 UTC
Starting with 192-b26 one cannot connect to a JVM for debugging anymore. The following works with:

Apache Maven 3.6.1-SNAPSHOT (abbb2604d4ced61ea5c50ce9b0796c1d1c04a2c6; 2019-01-06T20:03:37+01:00)
Maven home: /home/mosipov/apache-maven-3.6.1-SNAPSHOT
Java version: 1.8.0_181, vendor: Oracle Corporation, runtime: /usr/local/openjdk8/jre
Default locale: de_DE, platform encoding: UTF-8
OS name: "freebsd", version: "11.2-release-p7", arch: "i386", family: "unix"
$ ~/apache-maven-3.6.1-SNAPSHOT/bin/mvnDebug
Preparing to execute Maven in debug mode
Listening for transport dt_socket at address: 8000
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.785 s
[INFO] Finished at: 2019-01-07T00:16:58+01:00


I do attach to the JVM from Windows 10 with Eclipse.

Running the same with 8.0.192 Eclipse says: connection refused. I cannot terminate the process with Ctrl+C from the shell. I have so send SIGKILL.
Comment 1 Michael Osipov 2019-01-06 23:24:24 UTC
If I can provide further information, let me know.
Comment 2 Jonathan Chen 2019-01-07 00:09:06 UTC
I've just tried this 12.0-STABLE/amd64, and when maven starts up, there is a listener:
1:05pm> netstat -an | egrep "8000.*LISTEN"
tcp4       0      0 *.8000                 *.*                    LISTEN

But when connecting with Eclipe's remote debugger, the following internal error is reported (on Eclipse):

An internal error occurred during: "Launching Remote MyProject".
java.lang.NegativeArraySizeException

After this error, the listener on maven disappears:
1:07pm> netstat -an | egrep "8000.*LISTEN"
1:07pm>

Eclipse then reports:
Failed to connect to remote VM. Connection refused.
Connection refused (Connection refused)
Comment 3 Jonathan Chen 2019-01-07 00:10:25 UTC
Just for reference:

1:09pm> uname -a
FreeBSD irontree.solnet 12.0-STABLE FreeBSD 12.0-STABLE r342294 GENERIC  amd64
1:09pm> java -version
openjdk version "1.8.0_192"
OpenJDK Runtime Environment (build 1.8.0_192-b26)
OpenJDK 64-Bit Server VM (build 25.192-b26, mixed mode)
Comment 4 Jonathan Chen 2019-01-07 00:17:21 UTC
I've managed to locate Eclipse's error log entry:

!ENTRY org.eclipse.core.jobs 4 2 2019-01-07 13:07:32.848
!MESSAGE An internal error occurred during: "Launching Remote MyProject".
!STACK 0
java.lang.NegativeArraySizeException
    at org.eclipse.jdi.internal.jdwp.JdwpString.read(JdwpString.java:30)
    at org.eclipse.jdi.internal.MirrorImpl.readString(MirrorImpl.java:452)
    at org.eclipse.jdi.internal.VirtualMachineImpl.getVersionInfo(VirtualMachineImpl.java:1014)
    at org.eclipse.jdi.internal.VirtualMachineImpl.name(VirtualMachineImpl.java:930)
    at org.eclipse.jdt.internal.launching.SocketAttachConnector.constructVMLabel(SocketAttachConnector.java:174)
    at org.eclipse.jdt.internal.launching.SocketAttachConnector.connect(SocketAttachConnector.java:145)
    at org.eclipse.jdt.internal.launching.JavaRemoteApplicationLaunchConfigurationDelegate.launch(JavaRemoteApplicationL
aunchConfigurationDelegate.java:85)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:885)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:739)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1039)
    at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1256)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Comment 5 Jonathan Chen 2019-01-07 00:26:56 UTC
Looking at Eclipse's source code at this point in time from https://github.com/eclipse/eclipse.jdt.debug/blob/2ae2bfa90bb468fd74c09090aaa134e2a71fbfdd/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/jdwp/JdwpString.java

...
23 public class JdwpString {
24	/**
25	 * Reads String from Jdwp stream. Read a UTF where length has 4 bytes, and
26	 * not just 2. This code was based on the OTI Retysin source for readUTF.
27	 */
28	public static String read(DataInputStream in) throws IOException {
29		int utfSize = in.readInt();
30		byte utfBytes[] = new byte[utfSize];
Comment 6 Michael Osipov 2019-01-07 07:57:40 UTC
Jonathan,

this is the exact error I receive. Thanks for digging. Haven't had any time for this yet. I hardly doubt that this is an Eclipse bug.
Comment 7 huanghwh 2019-01-07 12:39:21 UTC
jdb also broken:
/usr/local/openjdk8-8.192/bin/jdb javaapplication1/JavaApplication1
Initializing jdb ...
> run
run javaapplication1/JavaApplication1
Exception in thread "JDI Internal Event Handler" java.lang.UnsupportedOperationException: JDWP: ID size not supported: 134217728
	at com.sun.tools.jdi.PacketStream.readID(PacketStream.java:410)
	at com.sun.tools.jdi.PacketStream.readObjectRef(PacketStream.java:418)
	at com.sun.tools.jdi.PacketStream.readThreadReference(PacketStream.java:445)
	at com.sun.tools.jdi.JDWP$Event$Composite$Events$VMStart.<init>(JDWP.java:7613)
	at com.sun.tools.jdi.JDWP$Event$Composite$Events.<init>(JDWP.java:7526)
	at com.sun.tools.jdi.JDWP$Event$Composite.<init>(JDWP.java:8594)
	at com.sun.tools.jdi.EventSetImpl.build(EventSetImpl.java:608)
	at com.sun.tools.jdi.EventQueueImpl.removeUnfiltered(EventQueueImpl.java:211)
	at com.sun.tools.jdi.EventQueueImpl.removeInternal(EventQueueImpl.java:124)
	at com.sun.tools.jdi.InternalEventHandler.run(InternalEventHandler.java:54)
	at java.lang.Thread.run(Thread.java:748)
Internal exception:
com.sun.jdi.InternalException: Unexpected JDWP Error: 113
	at com.sun.tools.jdi.JDWPException.toJDIException(JDWPException.java:65)
	at com.sun.tools.jdi.EventRequestManagerImpl$EventRequestImpl.set(EventRequestManagerImpl.java:204)
	at com.sun.tools.jdi.EventRequestManagerImpl$EventRequestImpl.setEnabled(EventRequestManagerImpl.java:166)
	at com.sun.tools.jdi.EventRequestManagerImpl$EventRequestImpl.enable(EventRequestManagerImpl.java:151)
	at com.sun.tools.example.debug.tty.EventRequestSpec.resolveEagerly(EventRequestSpec.java:139)
	at com.sun.tools.example.debug.tty.EventRequestSpecList.addEagerlyResolve(EventRequestSpecList.java:98)
	at com.sun.tools.example.debug.tty.Commands.resolveNow(Commands.java:1125)
	at com.sun.tools.example.debug.tty.Commands.commandCatchException(Commands.java:810)
	at com.sun.tools.example.debug.tty.VMConnection.setEventRequests(VMConnection.java:427)
	at com.sun.tools.example.debug.tty.VMConnection.open(VMConnection.java:337)
	at com.sun.tools.example.debug.tty.Commands.commandRun(Commands.java:559)
	at com.sun.tools.example.debug.tty.TTY.executeCommand(TTY.java:501)
	at com.sun.tools.example.debug.tty.TTY.<init>(TTY.java:781)
	at com.sun.tools.example.debug.tty.TTY.main(TTY.java:1083)
Comment 8 huanghwh 2019-01-08 00:22:04 UTC
jdb should send size=0x00000008, but sent 0x08000000.
Comment 9 Michael Osipov 2019-01-08 08:58:44 UTC
Note: reverting to 8.181 works as expected.
Comment 10 huanghwh 2019-02-09 15:48:07 UTC
openjdk8-8.192.26_5 fixed this bug.
Comment 11 Greg Lewis freebsd_committer freebsd_triage 2019-02-10 00:02:14 UTC
Thanks for testing with 8.192.26_5.  I'll close this.
Comment 12 Michael Osipov 2019-02-10 12:43:50 UTC
(In reply to Greg Lewis from comment #11)

I can confirm that the issue has been fixed. Thank you!