JDK-8257575 : C2: "failed: only phis" assert failure in loop strip mining verification
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11,16
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-12-02
  • Updated: 2024-09-30
  • Resolved: 2020-12-07
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 16
11.0.11-oracleFixed 16 b28Fixed
Related Reports
Relates :  
Relates :  
Description
#  Internal Error (/home/roland/jdk-jdk/src/hotspot/share/opto/loopnode.cpp:1812), pid=1215818, tid=1215833
#  assert(outer->outcnt() >= phis + 2 && outer->outcnt() <= phis + 2 + stores + 1) failed: only phis

from a ctw run but also reproducible with:

/**
 * @test
 *
 * @run main/othervm -XX:LoopUnrollLimit=0 -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestEliminatedLoadPinnedOnBackedge::notInlined
 *                    -XX:CompileCommand=inline,TestEliminatedLoadPinnedOnBackedge::inlined TestEliminatedLoadPinnedOnBackedge
 *
 */

public class TestEliminatedLoadPinnedOnBackedge {
    private static Object field2;

    final static int iters = 2000;

    public static void main(String[] args) {
        boolean[] flags = new boolean[iters];
        for (int i = 0; i < iters; i++) {
            flags[i] = i < iters/2;
        }
        for (int i = 0; i < 20_000; i++) {
            test1(flags);
            inlined(new Object(), 1);
            inlined(new Object(), 4);
            inlined2(42);
            inlined2(0x42);
        }
    }

    static int field;

    private static int test1(boolean[] flags) {
        int k = 2;
        for (; k < 4; k *= 2) {
        }
        int[] array = new int[10];
        notInlined(array);
        int v = array[0];
        array[1] = 42;
        Object o = new Object();
        inlined(o, k);
        int i = 0;
        for (; ; ) {
            synchronized (array) {
            }
            if (i >= iters) {
                break;
            }
            v = array[0];
            if (flags[i]) {
                inlined2(array[1]);
            }
            i++;
        }
        return v;
    }
}
Comments
Okay, too bad but thanks for checking!
30-09-2024

I find exactly two crashes in our DB with "outer->outcnt() >= phis + 2 - be_loads". Both are in test sun/security/tools/jarsigner/PreserveRawManifestEntryAndDigest.java and 17, one Aug 4th, 2023 windows x64, the other Sep 26th, 2024 macos x64. So it's quite rare.
30-09-2024

[~mbaesken], [~goetz] Can you reproduce this? If so, please file a new bug since the assert should be fixed in JDK 17u.
30-09-2024

I added the replay file for the failure reported by Matthias. It happened with a build of jdk17.0.13+9.
27-09-2024

Recently we saw the assertion when running test sun/security/tools/jarsigner/PreserveRawManifestEntryAndDigest.java macOS x86_64, jdk17 was used : # Internal Error (/priv/jenkins/client-home/workspace/openjdk-17u-macos_x86_64-dbg/jdk/src/hotspot/share/opto/loopnode.cpp:2025), pid=95572, tid=28419 # assert(outer->outcnt() >= phis + 2 - be_loads && outer->outcnt() <= phis + 2 + stores + 1) failed: only phis # # JRE version: OpenJDK Runtime Environment (17.0.13) (fastdebug build 17.0.13-internal+0-adhoc.sapmachine.jdk) Current CompileTask: C2: 985500 6452 4 sun.security.util.SignatureFileVerifier::processImpl (464 bytes) Stack: [0x000070000a006000,0x000070000a106000], sp=0x000070000a101860, free space=1006k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) V [libjvm.dylib+0x1245d8c] VMError::report_and_die(int, char const*, char const*, __va_list_tag*, Thread*, unsigned char*, void*, void*, char const*, int, unsigned long)+0x6dc V [libjvm.dylib+0x12463c8] VMError::report_and_die(Thread*, void*, char const*, int, char const*, char const*, __va_list_tag*)+0x38 V [libjvm.dylib+0x62e34d] report_vm_error(char const*, int, char const*, char const*, ...)+0xdd V [libjvm.dylib+0xc81e28] LoopNode::verify_strip_mined(int) const+0xc48 V [libjvm.dylib+0x5e04e8] Compile::final_graph_reshaping_impl(Node*, Final_Reshape_Counts&, Unique_Node_List&)+0x568 V [libjvm.dylib+0x5e38e0] Compile::final_graph_reshaping_walk(Node_Stack&, Node*, Final_Reshape_Counts&, Unique_Node_List&)+0x180 V [libjvm.dylib+0x5dcac4] Compile::final_graph_reshaping()+0x294 V [libjvm.dylib+0x5d3bdd] Compile::Optimize()+0x3cd V [libjvm.dylib+0x5d2264] Compile::Compile(ciEnv*, ciMethod*, int, bool, bool, bool, bool, bool, DirectiveSet*)+0x16e4 V [libjvm.dylib+0x4c6ce9] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x109 V [libjvm.dylib+0x5ef158] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x798 V [libjvm.dylib+0x5ee6e8] CompileBroker::compiler_thread_loop()+0x308 V [libjvm.dylib+0x119edbd] JavaThread::thread_main_inner()+0x26d V [libjvm.dylib+0x119bba7] Thread::call_run()+0x177 V [libjvm.dylib+0xe772a0] thread_native_entry(Thread*)+0x150 C [libsystem_pthread.dylib+0x618b] _pthread_start+0x63 C [libsystem_pthread.dylib+0x1ae3] thread_start+0xf
27-09-2024

Fix Request Should get backported for parity with 11.0.11-oracle. Applies cleanly.
12-01-2021

Changeset: f5a582c2 Author: Roland Westrelin <roland@openjdk.org> Date: 2020-12-07 09:38:22 +0000 URL: https://git.openjdk.java.net/jdk/commit/f5a582c2
07-12-2020

ILW = Harmless assert during C2 compilation, reproducible with simple test, no workaround but disable compilation = MMM = P3
04-12-2020

Nevermind, I see review request now. It looks like a slightly different problem.
02-12-2020

It started failing after JDK-8255000 (C2: Unify IGVN processing when loop opts are over) which delayed some post-loop opts IGVN transformations and node eliminations. It led to some Phi nodes to be commoned and shared in outer loop during strip mining and triggered the assertion failure.
02-12-2020

It duplicates JDK-8255120, doesn't it?
02-12-2020