JDK-8350971 : C2: assert(idx == alias_idx) failed: Following Phi nodes should be on the same memory slice
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 19,21,24,25,26
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: linux_ubuntu
  • CPU: x86_64
  • Submitted: 2025-02-26
  • Updated: 2025-05-09
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 26
26Unresolved
Related Reports
Causes :  
Description
The attached Test.java fails reliably with the following assertion:

$ java Test.java

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/opt/mach5/mesos/work_dir/slaves/d2398cde-9325-49c3-b030-8961a4f0a253-S159505/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/8cd8975f-aae7-42a6-825d-91ff5feb2ef0/runs/fd2688ee-df87-438e-994d-bdd923c21d85/workspace/open/src/hotspot/share/opto/escape.cpp:4080), pid=167688, tid=167707
#  assert(idx == alias_idx) failed: Following Phi nodes should be on the same memory slice
#
# JRE version: Java(TM) SE Runtime Environment (25.0+21) (fastdebug build 25-ea+21-LTS-2453)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 25-ea+21-LTS-2453, mixed mode, sharing, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0xd11cc3]  ConnectionGraph::move_inst_mem(Node*, GrowableArray<PhiNode*>&)+0x683
...............
C2:1425   30    b        Test::test (33 bytes)

Stack: [0x00007cbea2300000,0x00007cbea2400000],  sp=0x00007cbea23fa710,  free space=1001k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0xda156c]  ConnectionGraph::move_inst_mem(Node*, GrowableArray<PhiNode*>&)+0x8e8  (escape.cpp:4080)
V  [libjvm.so+0xda5ff8]  ConnectionGraph::split_unique_types(GrowableArray<Node*>&, GrowableArray<ArrayCopyNode*>&, GrowableArray<MergeMemNode*>&, Unique_Node_List&)+0x3b8c  (escape.cpp:4935)
V  [libjvm.so+0xd8f7f5]  ConnectionGraph::compute_escape()+0x1719  (escape.cpp:396)
V  [libjvm.so+0xd8e03c]  ConnectionGraph::do_analysis(Compile*, PhaseIterGVN*)+0x1ac  (escape.cpp:118)
V  [libjvm.so+0xb0e64d]  Compile::Optimize()+0xb1f  (compile.cpp:2396)
V  [libjvm.so+0xb06270]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1940  (compile.cpp:860)
V  [libjvm.so+0x9b9a14]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x486  (c2compiler.cpp:141)
V  [libjvm.so+0xb2e535]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0xe01  (compileBroker.cpp:2307)
V  [libjvm.so+0xb2c92e]  CompileBroker::compiler_thread_loop()+0x576  (compileBroker.cpp:1951)
V  [libjvm.so+0xb4ec23]  CompilerThread::thread_entry(JavaThread*, JavaThread*)+0x89  (compilerThread.cpp:67)
V  [libjvm.so+0x101bdbc]  JavaThread::thread_main_inner()+0x1b2  (javaThread.cpp:773)
V  [libjvm.so+0x101bc07]  JavaThread::run()+0x1d7  (javaThread.cpp:758)
V  [libjvm.so+0x18c96fd]  Thread::call_run()+0x1b9  (thread.cpp:231)
V  [libjvm.so+0x15ed8ff]  thread_native_entry(Thread*)+0x1f5  (os_linux.cpp:870)


======= Original report =======
ADDITIONAL SYSTEM INFORMATION :
java -version
openjdk version "25-internal" 2025-09-16
OpenJDK Runtime Environment (fastdebug build 25-internal-adhoc.user.jdk)
OpenJDK 64-Bit Server VM (fastdebug build 25-internal-adhoc.user.jdk, mixed mode)

A DESCRIPTION OF THE PROBLEM :
When I used the JVM compiled from the OpenJDK source code obtained from GitHub to run the following code, the JVM crashed. After enabling the -Xint option to disable JIT, the issue no longer occurred. Based on the location of the assert, we suspect that there is a bug in the C2 compiler of the JIT.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac Test.java & java Test

ACTUAL -
A crash may occur during runtime (about once in every three runs).

---------- BEGIN SOURCE ----------
class Test {
    static int[] iArrFld = new int[400];

    static int method9() {
        int[] more = { 94 };
        java.util.function.Predicate<Integer> check = m -> m == 0;
        java.util.function.IntConsumer decrement = x -> more[0]--;
        java.util.function.BooleanSupplier innerLoop = () -> {
            while (!check.test(more[0]))
                decrement.accept(0);
            return true;
        };
        innerLoop.getAsBoolean();
        java.util.function.BooleanSupplier process = () -> check.test(more[0]);
        while (!process.getAsBoolean()) {
        }
        return 0;
    }

    public static void main(String[] strArr) {
        int i14 = 1;
        do {
            iArrFld[i14] = 211;
            for (int i15 = 1; i15 < 4; ++i15)
                i14 = Test.method9();
        } while (i14 < 5);
    }
}

---------- END SOURCE ----------


Comments
Thanks [~kvn]! If you find a fix within time for JDK 25, feel free to re-target.
09-05-2025

Thank you, [~chagedorn], for creating reproducer. I will look when I have time.
08-05-2025

Starts to fail after JDK-8276455 which went into JDK 19+2
08-05-2025

Attached Test.java which reliably reproduces the issue way back to JDK 19. Since this is not a recent regression, I'm deferring this issue to JDK 26.
08-05-2025

I also reproduced it with exploded build. I used your commands from your comment.
13-03-2025

Some kind of uninitialized value or memory stomp?
07-03-2025

Interesting. I was able to reproduce it once on lab machine but then I can't reproduce it with new created replay file. I used latest JDK local build with latest EA fix JDK-8348261.
07-03-2025

ILW = Assertion during EA, single test and intermittent, -XX:-DoEscapeAnalysis or disable compilation of affected method = HLM = P3
07-03-2025

I could only reproduce it intermittently with an exploded build: jdk/build/linux-x64-debug/jdk/bin/javac Test.java jdk/build/linux-x64-debug/jdk/bin/java Test A non-exploded build did not work: jdk/build/linux-x64-debug/images/jdk/bin/java Test
07-03-2025

Mailed submitter =========== Hello When a product build crashes during C2 compilation, which seem to be the case in this issue, it not only generates an hs_err_file but also a replay_file with the message as below # Compiler replay data is saved as: # /home/XXXX/replay_pid433251.log Could you provide the specific replay log file. Could you test and confirm if the crash occurs with a JDK 25 early access build as well. Thanks
06-03-2025