JDK-8221568 : DataOutputStream/WriteUTF.java fails due to "OutOfMemoryError: Java heap space"
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 13
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86_64
  • Submitted: 2019-03-27
  • Updated: 2019-05-02
  • Resolved: 2019-03-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 13
13 b15Fixed
Related Reports
Cloners :  
Relates :  
Description
The following test failed in the JDK13 CI:

java/io/DataOutputStream/WriteUTF.java

Here's a snippet of the log file:

#section:testng
----------messages:(4/164)----------
command: testng -Xmx2g WriteUTF
reason: User specified action: run testng/othervm -Xmx2g WriteUTF 
Mode: othervm [/othervm specified]
elapsed time (seconds): 0.747
----------configuration:(0/0)----------
----------System.out:(45/2679)----------
[TestNG] Running:
  java/io/DataOutputStream/WriteUTF.java

test WriteUTF.arrayIndexOutOfBoundsException(): failure
java.lang.OutOfMemoryError: Java heap space
	at java.base/java.lang.String.repeat(String.java:3259)
	at WriteUTF.writeUTF(WriteUTF.java:50)
	at WriteUTF.arrayIndexOutOfBoundsException(WriteUTF.java:66)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
	at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:821)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1131)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
	at org.testng.TestRunner.privateRun(TestRunner.java:773)
	at org.testng.TestRunner.run(TestRunner.java:623)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
	at org.testng.SuiteRunner.run(SuiteRunner.java:259)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
	at org.testng.TestNG.run(TestNG.java:1018)
	at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:94)
	at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:54)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
	at java.base/java.lang.Thread.run(Thread.java:835)
test WriteUTF.overcountWrittenField(): success
test WriteUTF.utfDataFormatException(): success

===============================================
java/io/DataOutputStream/WriteUTF.java
Total tests run: 3, Failures: 1, Skips: 0
===============================================

----------System.err:(14/858)----------
java.lang.Exception: failures: 1
	at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:96)
	at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:54)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
	at java.base/java.lang.Thread.run(Thread.java:835)

JavaTest Message: Test threw exception: java.lang.Exception: failures: 1
JavaTest Message: shutting down test

STATUS:Failed.`main' threw exception: java.lang.Exception: failures: 1
----------rerun:(32/4438)*----------

With the '/othervm' and '-Xmx2g' options, I'm surprised this test failed
due to OutOfMemoryError.
Comments
[~dcubed] I don't really know. My only thought is that perhaps run in the context of the CI system a test might need more memory that when run in isolation on a local machine but I have no basis for that assertion. Originally this test required 4GB of heap but during code review it was pointed out that 2GB should be sufficient. I ran the code through the CI system before checking it in, but it's possible I ran the 4GB version but not the 2GB version. That might explain the discrepancy.
27-03-2019

[~bpb] - Any idea why the sudden need for more memory? Seems strange...
27-03-2019

Increasing heap as - * @run testng/othervm -Xmx2g WriteUTF + * @run testng/othervm -Xmx3g WriteUTF made the test pass on macosx-x64.
27-03-2019

Weird. This passes locally and passed in previous CI test runs. Will try the CI submission again for grins.
27-03-2019