JDK-8288204 : GVN Crash: assert() failed: correct memory chain
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 17.0.3,18,19,20,21
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux_ubuntu
  • CPU: x86_64
  • Submitted: 2022-06-09
  • Updated: 2023-01-05
  • Resolved: 2023-01-03
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 20 JDK 21 Other
20Fixed 21 b04Fixed naResolved
Related Reports
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Arch: x86_64
OS: Ubuntu 20.04.4 LTS
HotSpot
- openjdk version "17.0.5-internal" 2022-10-18
- OpenJDK Runtime Environment (fastdebug build 17.0.5-internal+0-adhoc.simon.my-jdk17u)
- OpenJDK 64-Bit Server VM (fastdebug build 17.0.5-internal+0-adhoc.simon.my-jdk17u, mixed mode, sharing)
javac: javac 17.0.5-internal

A DESCRIPTION OF THE PROBLEM :
Note, this is found in OpenJDK 17.0.5 (internal; https://github.com/openjdk/jdk17u-dev; commit 041924ab).

The following is part of the log:
```
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/zdata/congli/my-jdk17u/src/hotspot/share/opto/memnode.cpp:226), pid=2320806, tid=2321039
#  assert(phase->C->get_alias_index(t) == phase->C->get_alias_index(t_adr)) failed: correct memory chain
#
# JRE version: OpenJDK Runtime Environment (17.0.5) (fastdebug build 17.0.5-internal+0-adhoc.congli.my-jdk17u)
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 17.0.5-internal+0-adhoc.congli.my-jdk17u, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x14393eb]  MemNode::optimize_memory_chain(Node*, TypePtr const*, Node*, PhaseGVN*)+0x1ab
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#

---------------  S U M M A R Y ------------

Command Line: -Xmx1G -Xbatch Test

Host: amdsuplus3.inf.ethz.ch, AMD Ryzen Threadripper 3990X 64-Core Processor, 128 cores, 251G, Ubuntu 20.04.4 LTS
Time: Thu Jun  9 18:31:10 2022 CEST elapsed time: 0.533573 seconds (0d 0h 0m 0s)

---------------  T H R E A D  ---------------

Current thread (0x00007f93085e6e50):  JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=2321039, stack(0x00007f92d33fc000,0x00007f92d34fd000)]


Current CompileTask:
C2:    533   53 % !b  4       Test::mainTest @ 152 (220 bytes)

Stack: [0x00007f92d33fc000,0x00007f92d34fd000],  sp=0x00007f92d34f8300,  free space=1008k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x14393eb]  MemNode::optimize_memory_chain(Node*, TypePtr const*, Node*, PhaseGVN*)+0x1ab
V  [libjvm.so+0x1440ed3]  LoadNode::Ideal(PhaseGVN*, bool)+0x313
V  [libjvm.so+0x1611818]  PhaseIterGVN::transform_old(Node*)+0xb8
V  [libjvm.so+0x160a6de]  PhaseIterGVN::optimize()+0x7e
V  [libjvm.so+0xa49319]  Compile::Optimize()+0xa49
V  [libjvm.so+0xa4b1b6]  Compile::Compile(ciEnv*, ciMethod*, int, bool, bool, bool, bool, bool, DirectiveSet*)+0x1306
V  [libjvm.so+0x873806]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x646
V  [libjvm.so+0xa5ce99]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0x1029
V  [libjvm.so+0xa5dc88]  CompileBroker::compiler_thread_loop()+0x678
V  [libjvm.so+0x1a0b846]  JavaThread::thread_main_inner()+0x266
V  [libjvm.so+0x1a11a44]  Thread::call_run()+0x104
V  [libjvm.so+0x158987c]  thread_native_entry(Thread*)+0x10c
```

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. javac Test.java
2. java -Xbatch -Xmx1G Test

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No crashes
ACTUAL -
Crashed

---------- BEGIN SOURCE ----------
class Test {
  int N;
  double[] dArrFld;
  int[] iArrFld;

  int iMeth() {
    double dArr[] = new double[N];
    long meth_res = Double.doubleToLongBits(checkSum(dArr));
    return (int) meth_res;
  }

  void mainTest(String[] strArr1) {
    int i = 47864, i27 = 0, i32, i37 = 39;
    short s4 = 21959;
    float f4;
    i ^= iMeth();
    for (; ; ) {
      for (i32 = 1; i32 < 46; i32++) i27 += s4;
      do
        for (f4 = 1; f4 < 1; ++f4) {
          dArrFld[(int) f4] = 53586;
          iArrFld[i37] *= 92.656F;
          dArrFld = double1array(N, 2.89809);
        }
      while (++i37 < 46);
      for (int ax$5 = 4; ax$5 < 6167; )
        try {
          long[] ax$3 = {1};
          for (int ax$2 = 0; ax$2 < 100000; ) {
            for (long duration : ax$3) {}
            String ax$0 = "test";
            ax$0 = ax$0 + ax$0;
            ax$0 = ax$0 + ax$0;
          }
        } catch (Throwable ax$4) {
        } finally {
        }
    }
  }

  public static void main(String[] strArr) {
    Test _instance = new Test();
    _instance.mainTest(strArr);
  }


  public static double checkSum(double[] a) {
    double sum = 0;
    for (int j = 0; j < a.length; j++) {
      sum += (a[j] / (j + 1) + a[j] % (j + 1));
    }
    return sum;
  }


  public static double[] double1array(int sz, double seed) {
    double[] ret = new double[sz];
    init(ret, seed);
    return ret;
  }


  public static void init(double[] a, double seed) {
    for (int j = 0; j < a.length; j++) {
      a[j] = (j % 2 == 0) ? seed + j : seed - j;
    }
  }
}
---------- END SOURCE ----------

FREQUENCY : always



Comments
Changeset: a6a903d4 Author: Tobias Hartmann <thartmann@openjdk.org> Date: 2023-01-03 08:21:22 +0000 URL: https://git.openjdk.org/jdk/commit/a6a903d4b627bde85a311336ce25a7f5e25cf664
03-01-2023

Fix was pushed while main bug was targeted to JDK 20. Reset the main bug to fixed in 21 and copied the Robo Duke entry here.
03-01-2023

Changeset: 04591595 Author: Yi Yang <yyang@openjdk.org> Date: 2022-12-26 02:16:06 +0000 URL: https://git.openjdk.org/jdk/commit/04591595374e84cfbfe38d92bff4409105b28009
03-01-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk20/pull/80 Date: 2023-01-03 07:16:09 +0000
03-01-2023

This bug was targeted for JDK 20 but the fix was pushed into the JDK 21 repository. I'm backporting the fix to JDK 20.
03-01-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/9777 Date: 2022-08-05 15:23:45 +0000
06-08-2022

I did a quick investigation, it seems that JDK-8267687 don't cause this crash, it only revealed this crash. This crash is likely related to EA. I'll be back after more investigations.
01-08-2022

[~yyang], this seems to be a regression introduced by JDK-8267687. Could you please have a look?
27-07-2022

I narrowed it down to JDK-8267687 in JDK 17 b26.
27-07-2022

After backing out JDK-8272735, I can reproduce this with latest JDK 20.
25-07-2022

This does not reproduce anymore after JDK-8272735 in JDK 19 b14.
22-07-2022

I can reproduce this with JDK 17.0.5-ea+3-LTS-161 and JDK 18.0.2, attached is a simplified test (Test-1.java).
19-07-2022

ILW = assert in debug build; submitter can reproduce; no workaround = MMH = P3
25-06-2022

Issue is not reproduced on either GA or fastdebug Oracle JDK builds with the updated testcase. OS: Linux(ubuntu 20.04) JDK 8u333 : Pass JDK 11.0.15.1: Pass JDK 17.0.3.1: Pass JDK 18.0.1.1: Pass Since it is reproducible by the submitter in OpenJDK builds, reopening the issue for the community to look at it.
24-06-2022

Additional Information from submitter =========================== The provided `Test.java` is a reduced version of the original. If you cannot reproduce the crash, please download the original one (Test.java.orig) and try again from this link: <attached> The crash may occur after running the program for 1-2 min. So please be patient when reproducing.
22-06-2022

I can't reproduce it with a OpenJDK 17.0.5 build either. Maybe there is something about the hardware features that is triggering it.
11-06-2022

Issue is not reproduced on either GA or fastdebug build. Crash is not observed. OS: Linux(ubuntu 20.04) JDK 8u333 : Pass JDK 11.0.15.1: Pass JDK 17.0.3.1: Pass JDK 18.0.1.1: Pass Moving it to JDK for further analysis.
10-06-2022