JDK-8361699 : C2: assert(can_reduce_phi(n->as_Phi())) failed: Sanity: previous reducible Phi is no longer reducible before SUT
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 23
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux_ubuntu
  • CPU: x86_64
  • Submitted: 2025-07-08
  • Updated: 2025-09-23
  • Resolved: 2025-09-17
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
26 b16Fixed
Related Reports
Causes :  
Description
ADDITIONAL SYSTEM INFORMATION :
$java -version
openjdk version "26-internal" 2026-03-17
OpenJDK Runtime Environment (fastdebug build 26-internal-adhoc.user.jdk-mainline)
OpenJDK 64-Bit Server VM (fastdebug build 26-internal-adhoc.user.jdk-mainline, mixed mode)

A DESCRIPTION OF THE PROBLEM :
We encountered the problem of jdk crash when running the following code using the jdk compiled from the source code obtained from the github jdk repository.

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (**src/hotspot/share/opto/escape.cpp:384), pid=1780742, tid=1780782
#  assert(can_reduce_phi(n->as_Phi())) failed: Sanity: previous reducible Phi is no longer reducible before SUT.
#
# JRE version: OpenJDK Runtime Environment (26.0) (fastdebug build 26-internal-adhoc.user.jdk-mainline)
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 26-internal-adhoc.user.jdk-mainline, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0xd66ffc]  ConnectionGraph::compute_escape()+0x243c
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -F%F -- %E" (or dumping to /data2/user/Artemis/toreport/8/reduce/core.1780742)
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#

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

ACTUAL -
 322  Proj  === 310  [[ 323 327 ]] #5 !jvms: Test$Ci::foo2 @ bci:42 (line 21)
 155  Proj  === 143  [[ 156 160 ]] #5 !jvms: Test$Ci::foo2 @ bci:15 (line 17)
 157  Proj  === 156  [[ 368 160 ]] #0 !orig=[211] !jvms: Test$Ci::foo2 @ bci:15 (line 17)
 324  Proj  === 323  [[ 337 327 ]] #0 !jvms: Test$Ci::foo2 @ bci:42 (line 21)
 294  Region  === 294 316 370  [[ 294 337 331 332 333 334 ]] #reducible  !jvms: Test$Ci::foo2 @ bci:49 (line 22)
 327  CheckCastPP  === 324 322  [[ 358 ]]  #byte[int:10] (java/lang/Cloneable,java/io/Serializable):NotNull:exact * !jvms: Test$Ci::foo2 @ bci:42 (line 21)
 160  CheckCastPP  === 157 155  [[ 358 292 310 ]]  #java/lang/Object:NotNull:exact *  Oop:java/lang/Object:NotNull:exact * !orig=[252],261 !jvms: Test$Ci::foo2 @ bci:15 (line 17)
 337  Region  === 337 294 324  [[ 337 361 347 358 349 350 351 352 353 354 ]] #reducible  !jvms: Test$Ci::foo2 @ bci:51 (line 25)
 358  Phi  === 337 160 327  [[ 361 ]]  #java/lang/Object:NotNull *  Oop:java/lang/Object:NotNull * !jvms: Test$Ci::foo2 @ bci:51 (line 25)
 358  Phi  === 337 160 327  [[ 361 ]]  #java/lang/Object:NotNull *  Oop:java/lang/Object:NotNull * !jvms: Test$Ci::foo2 @ bci:51 (line 25)
 361  CallStaticJava  === 337 347 307 8 9 (360 1 11 12 65 358 191 1 12 ) [[ 362 ]] # Static uncommon_trap(reason='uninitialized' action='reinterpret' debug_id='0')  void ( int ) C=0.000100 Test$Ci::foo2 @ bci:52 (line 25) !jvms: Test$Ci::foo2 @ bci:52 (line 25)
 362  Proj  === 361  [[ 365 ]] #0 !jvms: Test$Ci::foo2 @ bci:52 (line 25)
Can NOT reduce Phi 358 on invocation 0. No SR Allocate as input.
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (**src/hotspot/share/opto/escape.cpp:384), pid=1860485, tid=1860499
#  assert(can_reduce_phi(n->as_Phi())) failed: Sanity: previous reducible Phi is no longer reducible before SUT.
#
# JRE version: OpenJDK Runtime Environment (26.0) (fastdebug build 26-internal-adhoc.user.jdk-mainline)
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 26-internal-adhoc.user.jdk-mainline, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0xd5b88c]  ConnectionGraph::compute_escape()+0x243c
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -F%F -- %E" (or dumping to /data2/user/Artemis/toreport/8/reduce/core.1860485)
#
# An error report file with more information is saved as:
# /data2/user/Artemis/toreport/8/reduce/hs_err_pid1860485.log
#
# Compiler replay data is saved as:
# /data2/user/Artemis/toreport/8/reduce/replay_pid1860485.log
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#


---------- BEGIN SOURCE ----------
import java.util.zip.GZIPInputStream;

public class Test {
    abstract class Ci_abs {
        abstract void foo(int int1);
    }

    class Ci extends Ci_abs {
        @Override
        void foo(int int1) {
            GZIPInputStream gzipInputStream = null;
            foo2(int1, gzipInputStream);
        }

        void foo2(int i1, GZIPInputStream gzipInputStream) {
            Object[] objects = { new Object() };
            Object object = new Object();
            for (int i = -15; i < 1500000; i++) {
                try {
                    objects[i1] = object;
                    object = new byte[10];
                } catch (Throwable t) {
                }
                try {
                    gzipInputStream.read();
                } catch (Throwable t2) {
                }
            }
        }
    }

    public static void main(String[] args) {
        Test Test1 = new Test();
        Ci_abs Ci_abs1 = Test1.new Ci();
        int int1 = 498972445;
        Ci_abs1.foo(int1);
    }
}
---------- END SOURCE ----------

FREQUENCY : always



Comments
What's the release mode behavior for this bug? Is this "just" an assertion problem, or we don't know if it breaks compilation further and is able to miscompile?
18-09-2025

Changeset: 6f493b4d Branch: master Author: Cesar Soares Lucas <cslucas@openjdk.org> Date: 2025-09-17 16:52:13 +0000 URL: https://git.openjdk.org/jdk/commit/6f493b4d2e7120cbe34fb70d595f7626655b47a9
17-09-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/27063 Date: 2025-09-03 00:53:59 +0000
03-09-2025

Thanks, Christian. I'll take a look.
16-08-2025

ILW = HLM = P3 Impact = High, due to crash, on default vm arguments. Likelihood - Low, not found so far and it is rare case. Workaround - Excluding the crashing method from compilation
09-07-2025

Could trace back to JDK 23+18 where JDK-8316991 went in which added support for reducing nullable allocation merges. Will do a more narrow bisection to double-check. [~cslucas] could you have a look? Edit: Confirmed that it starts to fail after JDK-8316991
09-07-2025

ILW = Assertion failure in EA when reducing phis, single test, use -XX:-ReduceAllocationMerges = HLM = P3
09-07-2025

I've attached a simpler reproducer: $ java -XX:CompileCommand=compileonly,*Reduced*::* -Xbatch Reduced.java
09-07-2025