Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8277447

Hotspot C1 compiler crashes on Kotlin suspend fun with loop

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b29

      Backports

        Description

        The crashes have been observed with a release build of JDK, but a reliable reproducer requires a [fast]debug build where an assertion failure occurs in C1 code:

        # To suppress the following error report, specify this argument
        # after -XX: or in .hotspotrc: SuppressErrorAt=/c1_Instruction.cpp:849
        #
        # A fatal error has been detected by the Java Runtime Environment:
        #
        # Internal Error (/opt/buildAgent/work/bc84ff8f5e63b59d/src/hotspot/share/c1/c1_Instruction.cpp:849), pid=426790, tid=426803
        # assert(existing_value == new_state->local_at(index) || (existing_value->as_Phi() != __null && existing_value->as_Phi()->as_Phi()->block() == this)) failed: phi function required
        ...


        The original crash occurs when running IntelliJ IDEA, but a heavily reduced sample is presented here. To reproduce:
        1. Compile this Kotlin code

        $ cat Main.kt
        suspend fun yield(s: String) {
            println("Success");
            System.exit(0)
        }

        suspend fun test(s: String) {
            while (true) {
                yield(s)
            }
        }

        suspend fun main() {
            test("")
        }

        like so

        $ kotlinc Main.kt -include-runtime -d test.jar

        Alternatively, download the attached test.jar.

        2. Run a [fast]debug build of java with these options

        $ java -Xcomp -XX:CompileCommand=compileonly,MainKt::test -cp ./test.jar MainKt


        3. Observe the crash

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

        Current thread (0x00007f679c3a6800): JavaThread "C1 CompilerThread0" daemon [_thread_in_native, id=1253817, stack(0x00007f676d489000,0x00007f676d58a000)]


        Current CompileTask:
        C1: 11798 29 b 3 MainKt::test (136 bytes)

        Stack: [0x00007f676d489000,0x00007f676d58a000], sp=0x00007f676d5878f0, free space=1018k
        Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
        V [libjvm.so+0x1a7be8a] VMError::report_and_die(int, char const*, char const*, __va_list_tag*, Thread*, unsigned char*, void*, void*, char const*, int, unsigned long)+0x38a
        V [libjvm.so+0x1a7cdc5] VMError::report_and_die(Thread*, void*, char const*, int, char const*, char const*, __va_list_tag*)+0x35
        V [libjvm.so+0xc25eaa] report_vm_error(char const*, int, char const*, char const*, ...)+0x10a
        V [libjvm.so+0x80d773] BlockBegin::try_merge(ValueStack*)+0x2b23
        V [libjvm.so+0x7ee722] GraphBuilder::iterate_bytecodes_for_block(int)+0x732
        V [libjvm.so+0x7f05b0] GraphBuilder::iterate_all_blocks(bool)+0x80
        V [libjvm.so+0x7f18a7] GraphBuilder::GraphBuilder(Compilation*, IRScope*)+0x467
        V [libjvm.so+0x804654] IR::IR(Compilation*, ciMethod*, int)+0x684
        V [libjvm.so+0x7bcaf6] Compilation::build_hir() [clone .part.0]+0x276
        V [libjvm.so+0x7c21b0] Compilation::compile_java_method()+0x1c0
        V [libjvm.so+0x7c3308] Compilation::compile_method()+0x1d8
        V [libjvm.so+0x7c3eae] Compilation::Compilation(AbstractCompiler*, ciEnv*, ciMethod*, int, BufferBlob*, DirectiveSet*)+0x32e
        V [libjvm.so+0x7c4d53] Compiler::compile_method(ciEnv*, ciMethod*, int, DirectiveSet*)+0x143
        V [libjvm.so+0xb4acb5] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x785
        V [libjvm.so+0xb4cb28] CompileBroker::compiler_thread_loop()+0x678
        V [libjvm.so+0x19b105e] JavaThread::thread_main_inner()+0x2ee
        V [libjvm.so+0x19b13f8] JavaThread::run()+0x218
        V [libjvm.so+0x19a8e2b] Thread::call_run()+0xbb
        V [libjvm.so+0x1699886] thread_native_entry(Thread*)+0x116

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                iveresov Igor Veresov
                Reporter:
                mkartashev Maxim Kartashev
                Votes:
                0 Vote for this issue
                Watchers:
                10 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: