JDK-8235332 : TestInstanceCloneAsLoadsStores.java fails with -XX:+StressGCM
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11,12,13,14,15
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-12-04
  • Updated: 2020-06-24
  • Resolved: 2020-01-31
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 11 JDK 13 JDK 14 JDK 15
11.0.8-oracleFixed 13.0.4Fixed 14.0.2Fixed 15 b09Fixed
Related Reports
Relates :  
Description
test/hotspot/jtreg/compiler/arraycopy/TestInstanceCloneAsLoadsStores.java

CompileCommand: dontinline compiler/arraycopy/TestInstanceCloneAsLoadsStores.m*
Test m3 failed
source: 
int compiler.arraycopy.TestInstanceCloneUtils$E.i1 = 0
int compiler.arraycopy.TestInstanceCloneUtils$E.i2 = 1
int compiler.arraycopy.TestInstanceCloneUtils$E.i3 = 2
int compiler.arraycopy.TestInstanceCloneUtils$E.i4 = 3
int compiler.arraycopy.TestInstanceCloneUtils$E.i5 = 4
int compiler.arraycopy.TestInstanceCloneUtils$E.i6 = 5
int compiler.arraycopy.TestInstanceCloneUtils$E.i7 = 6
int compiler.arraycopy.TestInstanceCloneUtils$E.i8 = 7
int compiler.arraycopy.TestInstanceCloneUtils$E.i9 = 8
result: 
-714222088
STDERR:
java.lang.RuntimeException: some tests failed
	at compiler.arraycopy.TestInstanceCloneAsLoadsStores.main(TestInstanceCloneAsLoadsStores.java:110)
	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:564)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
	at java.base/java.lang.Thread.run(Thread.java:832)

JavaTest Message: Test threw exception: java.lang.RuntimeException: some tests failed
JavaTest Message: shutting down test

STATUS:Failed.`main' threw exception: java.lang.RuntimeException: some tests failed
rerun:
cd /oracle/jdk_jdk/open/JTwork/scratch && \
DISPLAY=:0 \
GNOME_DESKTOP_SESSION_ID=this-is-deprecated \
HOME=/home/tobias \
LANG=en_US.UTF-8 \
LD_LIBRARY_PATH=/oracle/documents/misc/ \
PATH=/bin:/usr/bin \
XMODIFIERS=@im=ibus \
CLASSPATH=/oracle/jdk_jdk/open/JTwork/classes/compiler/arraycopy/TestInstanceCloneAsLoadsStores.d:/oracle/jdk_jdk/open/test/hotspot/jtreg/compiler/arraycopy:/oracle/jdk_jdk/open/JTwork/classes:/oracle/jdk_jdk/open/test/hotspot/jtreg:/home/tobias/programs/jtreg/lib/javatest.jar:/home/tobias/programs/jtreg/lib/jtreg.jar \
    /oracle/jdk_jdk/build/linux-x86_64-server-fastdebug/jdk/bin/java \
        -Dtest.src=/oracle/jdk_jdk/open/test/hotspot/jtreg/compiler/arraycopy \
        -Dtest.src.path=/oracle/jdk_jdk/open/test/hotspot/jtreg/compiler/arraycopy:/oracle/jdk_jdk/open/test/hotspot/jtreg \
        -Dtest.classes=/oracle/jdk_jdk/open/JTwork/classes/compiler/arraycopy/TestInstanceCloneAsLoadsStores.d \
        -Dtest.class.path=/oracle/jdk_jdk/open/JTwork/classes/compiler/arraycopy/TestInstanceCloneAsLoadsStores.d:/oracle/jdk_jdk/open/JTwork/classes \
        -Dtest.vm.opts= \
        -Dtest.tool.vm.opts= \
        -Dtest.compiler.opts= \
        -Dtest.java.opts=-XX:+StressGCM \
        -Dtest.jdk=/oracle/jdk_jdk/build/linux-x86_64-server-fastdebug/jdk \
        -Dcompile.jdk=/oracle/jdk_jdk/build/linux-x86_64-server-fastdebug/jdk \
        -Dtest.timeout.factor=4.0 \
        -Dtest.root=/oracle/jdk_jdk/open/test/hotspot/jtreg \
        -XX:+StressGCM \
        -XX:-BackgroundCompilation \
        -XX:-UseOnStackReplacement \
        -XX:CompileCommand=dontinline,compiler.arraycopy.TestInstanceCloneAsLoadsStores::m* \
        -XX:+IgnoreUnrecognizedVMOptions \
        -XX:-ReduceInitialCardMarks \
        com.sun.javatest.regtest.agent.MainWrapper /oracle/jdk_jdk/open/JTwork/compiler/arraycopy/TestInstanceCloneAsLoadsStores.d/main.2.jta

TEST RESULT: Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: some tests failed

Comments
Fix request (13u) I would like to downport this. Applies clean. Test passes, Tier1 passes.
04-06-2020

Fix request (11u) -- will label after testing completed. I would like to downport this for parity with 11.0.8-oracle. Applies clean.
17-03-2020

Fix Request (JDK 14.0.2) The patch fixes a wrong compilation with C2 which may lead to wrong execution and has already been backported to JDK 11u. The fix is low risk and applies cleanly to JDK 14.0.2. In addition to CI testing through all tiers in JDK 15 and 11u, additional testing will be executed in JDK 14.0.2 before pushing.
06-03-2020

Changeset: b940e17c Author: Christian Hagedorn <chagedorn@openjdk.org> Date: 2020-01-31 09:32:00 +0000 URL: https://git.openjdk.java.net/panama-foreign/commit/b940e17c
07-02-2020

URL: https://hg.openjdk.java.net/jdk/jdk/rev/0905868db490 User: chagedorn Date: 2020-01-31 08:36:49 +0000
31-01-2020

http://cr.openjdk.java.net/~chagedorn/8235332/webrev.00/ An ArrayCopyNode for a clone is not inlined for more than 8 (=ArrayCopyLoadStoreMaxElem) fields. Therefore, the test cases uses 9 fields. There is a GC barrier for 109 ArrayCopy [1] when disabling ReduceInitialCardMarks which is not taken into account in the pattern matching check for a clone at [2] in ConnectionGraph::find_inst_mem() during escape analysis. As a result, 161 MemBarStoreStore is skipped and the search continues at 160 MergeMem and the result is set to 97 Proj at [3]. Escape Analysis will then optimize 171 LoadI to directly use the memory output of the uninitialized allocation instead of the output of the ArrayCopyNode because it thinks the memory is the same [4]. This bug, however, is only observed when enabling the StressGCM flag which emits the field loading code before the array copy code which results in reads from uninitialized memory. The existing pattern matching code to find an ArrayCopyNode over the MergeMemNode is replaced by a pattern matching over the MemBarNode taking GC barriers into account. [1] https://bugs.openjdk.java.net/secure/attachment/86398/array_copy_with_gc_barrier.png [2] http://hg.openjdk.java.net/jdk/jdk/file/f7edb9ca045c/src/hotspot/share/opto/escape.cpp#l2749 [3] http://hg.openjdk.java.net/jdk/jdk/file/f7edb9ca045c/src/hotspot/share/opto/escape.cpp#l2765 [4] https://bugs.openjdk.java.net/secure/attachment/86397/field_load_wrong_memory.png
14-01-2020

Reproduces with JDK 11 but not with 8
10-12-2019

ILW = Incorrect execution of compiled code, single test with stress flag, disable stress flag or compilation of affected method = HLM = P3
04-12-2019