Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JTReg failure: java/math/BigInteger/largeMemory/SymmetricRangeTests.java #8728

Closed
lumpfish opened this issue Mar 3, 2020 · 11 comments
Closed

Comments

@lumpfish
Copy link
Contributor

lumpfish commented Mar 3, 2020

Failure has been reported at AdoptOpenJDK as intermittent on Windows, Windows XL and AIX jdk14, though the isolated test case below also fails locally on jdk11.0.6+10_openj9-0.18.1 on linux_x86-64.
The test is annotated with

@requires os.maxMemory > 8g

so it may be that it is not the failure which is intermittent, but the execution of the test itself. Certainly there are 'passed' test runs where this particular test does not appear in the list of tests executed.

The investigation below was all done locally on a Windows 10 laptop.

Test fails with

Testing overflow in BigInteger.makePositive
Testing Bug 8021204

java.lang.OutOfMemoryError
	at java.base/java.lang.AbstractStringBuilder.hugeCapacity(AbstractStringBuilder.java:269)
	at java.base/java.lang.AbstractStringBuilder.newCapacity(AbstractStringBuilder.java:261)
	at java.base/java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:228)
	at java.base/java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:808)
	at java.base/java.lang.StringBuilder.append(StringBuilder.java:240)
	at SymmetricRangeTests.testBug8021204(SymmetricRangeTests.java:103)
	at SymmetricRangeTests.main(SymmetricRangeTests.java:625)

The OOM is happening during the initialisation of a string buffer.
The code below reproduces the problem.
jdk11 and jdk14 throw the OOM, jdk8 does not. I have tested back as far as jdk-11.0.4+11 and that fails as well as current nightly builds.
The latest hotspot jdk11 builds do not throw the OOM exception.

public class StringBufferTest {
        
    public static void main(String[] args) {
        System.out.println("Trace 1");
        StringBuilder sb = new StringBuilder();
        sb.append('1');
        for (int i = 0; i < (1 << 30) - 1; i++) {
            sb.append('0');
        }
        System.out.println("Trace 2");
    }
}
@pshipton
Copy link
Member

pshipton commented Mar 3, 2020

@lumpfish what -Xmx value are you using to run the small testcase? Does it work with a bigger -Xmx value? If you aren't setting any -Xmx, pls run with -verbose:gc to see the default setting on your test machine.

@lumpfish
Copy link
Contributor Author

lumpfish commented Mar 3, 2020

The real test is run with -Xmx8g.
The small test case fails on a Windows 32Gb laptop with no -Xmx, -Xmx8g or -Xmx16g.

There is a difference in output running with -Xmx8g vs. -Xmx1g:

-Xmx8g:

jdk-11.0.4+11\bin\java -Xmx8g StringBufferTest
Trace 1
Exception in thread "main" java.lang.OutOfMemoryError
        at java.base/java.lang.AbstractStringBuilder.hugeCapacity(AbstractStringBuilder.java:214)
        at java.base/java.lang.AbstractStringBuilder.newCapacity(AbstractStringBuilder.java:206)
        at java.base/java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:173)
        at java.base/java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:748)
        at java.base/java.lang.StringBuilder.append(StringBuilder.java:241)
        at StringBufferTest.main(StringBufferTest.java:8)

-Xmx1g

jdk-11.0.4+11\bin\java -Xmx1g StringBufferTest
Trace 1
JVMDUMP039I Processing dump event "systhrow", detail "java/lang/OutOfMemoryError" at 2020/03/03 16:03:11 - please wait.
JVMDUMP032I JVM requested System dump using 'C:\Users\username\java\core.20200303.160311.22560.0001.dmp' in response to an event
JVMDUMP010I System dump written to C:\Users\username\java\core.20200303.160311.22560.0001.dmp
JVMDUMP032I JVM requested Heap dump using 'C:\Users\username\java\heapdump.20200303.160311.22560.0002.phd' in response to an event
JVMDUMP010I Heap dump written to C:\Users\username\java\heapdump.20200303.160311.22560.0002.phd
JVMDUMP032I JVM requested Java dump using 'C:\Users\username\java\javacore.20200303.160311.22560.0003.txt' in response to an event
JVMDUMP010I Java dump written to C:\Users\username\java\javacore.20200303.160311.22560.0003.txt
JVMDUMP032I JVM requested Snap dump using 'C:\Users\username\java\Snap.20200303.160311.22560.0004.trc' in response to an event
JVMDUMP010I Snap dump written to C:\Users\username\java\Snap.20200303.160311.22560.0004.trc
JVMDUMP013I Processed dump event "systhrow", detail "java/lang/OutOfMemoryError".
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        at java.base/java.util.Arrays.copyOf(Arrays.java:3776)
        at java.base/java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:172)
        at java.base/java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:748)
        at java.base/java.lang.StringBuilder.append(StringBuilder.java:241)
        at StringBufferTest.main(StringBufferTest.java:8)

@pshipton
Copy link
Member

pshipton commented Mar 4, 2020

The following occurs on OpenJ9 because -XX:-CompactStrings is the default, unlike Hotspot where the default is -XX:+CompactStrings. When running OpenJ9 with -XX:+CompactStrings the behavior should be the same as Hotspot (or vice versa).

java.lang.OutOfMemoryError
	at java.base/java.lang.AbstractStringBuilder.hugeCapacity(AbstractStringBuilder.java:269)

@pshipton
Copy link
Member

pshipton commented Mar 4, 2020

Note OpenJ9 JDK8 is different because it has it's own implementation of StringBuilder (and StringBuffer) rather than using the OpenJDK impl.

@lumpfish
Copy link
Contributor Author

lumpfish commented Mar 4, 2020

I have confirmed that the small test case passes with -XX:+CompactStrings.
So I guess we should exclude this test for open9 jdks later than jdk8 unless / until the default setting is changed for openj9.

@pshipton
Copy link
Member

pshipton commented Mar 4, 2020

So I guess we should exclude this test for open9 jdks later than jdk8 unless / until the default setting is changed for openj9.

Seems so, unless we can modify it to specify -XX:+CompactStrings

@lumpfish
Copy link
Contributor Author

lumpfish commented Mar 5, 2020

Seems so, unless we can modify it to specify -XX:+CompactStrings

We'll pursue adding the option to the test at openjdk.
I've also confirmed that hotspot jdks fail with -XX:-CompactStrings

@smlambert
Copy link
Contributor

Excluded via: adoptium/aqa-tests#1666

@pshipton
Copy link
Member

Since the cause of the failure is the test, I think this can be closed. I'll go ahead, but can reopen if someone disagrees.

@lumpfish
Copy link
Contributor Author

@smlambert
Copy link
Contributor

Test reincluded: adoptium/aqa-tests#1694

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants