question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Messages bigger than 65535 utf code points crash the server

See original GitHub issue

common/Message uses DataOutputStream#writeUTF which throws an expiation if the string to write is longer than 65535 utf code points

https://github.com/mvndaemon/mvnd/blob/master/common/src/main/java/org/jboss/fuse/mvnd/common/Message.java#L302

I stumbled upon this while trying mvnd with Neo4j-OGM. It happens while our build triggers the Maven Java doc plugin.

I was able to reproduce it with the following test:

package com.example.mvndtest;

import java.io.IOException;

import org.junit.jupiter.api.Test;

class MvndTestApplicationTests {

	@Test
	void contextLoads() throws IOException {

		var stringToWrite = new StringBuilder();
		for (int i = 0; i < 65535 /* 65509 works on my machine */; ++i) {
			stringToWrite.append("a");
		}

		System.out.println(stringToWrite.toString());
	}
}

Having such an output somewhere in the build - doesn’t matter via plugin or code - will crash the server. I wasn’t able to reproduce it with exec maven or ant run plugins and the reason is simple: Those plugins redirect sys out line by line. The java doc plugin however collects all the log from the javadoc binary and passes it directly to the maven log.

That’s basically the same like I do in the example above.

I have attached a reproducer.

mvn clean package works nicely with a lot of useless output, mvnd clean package will end with:

[INFO] Running com.example.mvndtest.MvndTestApplicationTests
Exception in thread "main" org.jboss.fuse.mvnd.common.DaemonException$StaleAddressException: Could not receive a message from the daemon.
	at org.jboss.fuse.mvnd.client.DaemonClientConnection.receive(DaemonClientConnection.java:107)
	at org.jboss.fuse.mvnd.client.DefaultClient.execute(DefaultClient.java:198)
	at org.jboss.fuse.mvnd.client.DefaultClient.main(DefaultClient.java:72)
Caused by: java.io.IOException: No message received within 3000ms, daemon may have crashed
	at org.jboss.fuse.mvnd.client.DaemonClientConnection.receive(DaemonClientConnection.java:100)
	... 2 more

and attached logs.

Reproducer: mvnd-test.zip

Logs: logs.zip

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ppalagacommented, Oct 26, 2020

Interesting! Thanks for the report, @michael-simons!

0reactions
gnodetcommented, Oct 26, 2020

UTF-8 varies in length between 2 and 4. The 💩 emoji for example is a 4 byte utf character I used on various occasions to break things: https://info.michael-simons.eu/2013/01/21/java-mysql-and-multi-byte-utf-8-support/

The serializer looks actually sensible.

No, I was talking about the length of the string. The DataOutputStream uses an unsigned short (2 bytes) so is limited to 64k. The DataOutputStream code code has the following https://github.com/openjdk-mirror/jdk7u-jdk/blob/master/src/share/classes/java/io/DataOutputStream.java#L363-L365:

        if (utflen > 65535)
            throw new UTFDataFormatException(
                "encoded string too long: " + utflen + " bytes");
Read more comments on GitHub >

github_iconTop Results From Across the Web

Messages bigger than 65535 utf code points crash the server
common/Message uses DataOutputStream#writeUTF which throws an expiation if the string to write is longer than 65535 utf code points ...
Read more >
How to fix "The code of method .. is exceeding the 65535 ...
In java a methods can't have more than 65535 bytes. So to fix this problem, break up your main(String[] args) method in to...
Read more >
Unicode Escape Sequences Across Various Languages and ...
Unicode escape sequences across various languages and platforms (including Supplementary Characters), with working examples.
Read more >
Computer Science - BetterExplained
But what about errors: if the server crashed, the file wasn't there, or google just didn't like us? Some metadata (data about data)...
Read more >
Changes to pfaedit (predecessor to fontforge)
At Werner's suggestion added code to show what points are affected by a ... Fixed a crash when referring to a character whose...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found