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

C2 crashes with assert(field != __null) failed: missing field

XMLWordPrintable

    • b09

        # Symptom

        ```
        #
        # A fatal error has been detected by the Java Runtime Environment:
        #
        # Internal Error (../jdk/src/hotspot/share/opto/type.cpp:3023), pid=25278, tid=40451
        # assert(field != __null) failed: missing field
        #

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

        Current thread (0x00007f8db7009820): JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=40451, stack(0x0000700009e5e000,0x0000700009f5e000)]


        Current CompileTask:
        C2: 213 8 b UnsafeAccessCompileTest::test (15 bytes)

        Stack: [0x0000700009e5e000,0x0000700009f5e000], sp=0x0000700009f57c40, free space=999k
        Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
        V [libjvm.dylib+0x110f0aa] VMError::report_and_die(int, char const*, char const*, __va_list_tag*, Thread*, unsigned char*, void*, void*, char const*, int, unsigned long)+0x7fa
        V [libjvm.dylib+0x110f969] VMError::report_and_die(Thread*, void*, char const*, int, char const*, char const*, __va_list_tag*)+0x89
        V [libjvm.dylib+0x549703] report_vm_error(char const*, int, char const*, char const*, ...)+0x283
        V [libjvm.dylib+0x109db26] TypeOopPtr::TypeOopPtr(Type::TYPES, TypePtr::PTR, ciKlass*, bool, ciObject*, int, int, TypePtr const*, int)+0x556
        V [libjvm.dylib+0x109f5bc] TypeInstPtr::TypeInstPtr(TypePtr::PTR, ciKlass*, bool, ciObject*, int, int, TypePtr const*, int)+0x9c
        V [libjvm.dylib+0x109f6cb] TypeInstPtr::TypeInstPtr(TypePtr::PTR, ciKlass*, bool, ciObject*, int, int, TypePtr const*, int)+0x7b
        V [libjvm.dylib+0x1096413] TypeInstPtr::make(TypePtr::PTR, ciKlass*, bool, ciObject*, int, int, TypePtr const*, int)+0x263
        V [libjvm.dylib+0x10a1b63] TypeInstPtr::add_offset(long) const+0xb3
        V [libjvm.dylib+0x1e788e] AddPNode::Value(PhaseGVN*) const+0x10e
        V [libjvm.dylib+0xe0a13c] PhaseGVN::transform_no_reclaim(Node*)+0x12c
        V [libjvm.dylib+0xe09ffd] PhaseGVN::transform(Node*)+0x1d
        V [libjvm.dylib+0x79cb22] GraphKit::basic_plus_adr(Node*, Node*, Node*)+0xb2
        V [libjvm.dylib+0xba7c19] GraphKit::basic_plus_adr(Node*, Node*)+0x29
        V [libjvm.dylib+0xba3680] LibraryCallKit::make_unsafe_address(Node*&, Node*, unsigned long long, BasicType, bool)+0x480
        V [libjvm.dylib+0xb8c332] LibraryCallKit::inline_unsafe_access(bool, BasicType, LibraryCallKit::AccessKind, bool)+0x5c2
        V [libjvm.dylib+0xb8344e] LibraryCallKit::try_to_inline(int)+0x51e
        V [libjvm.dylib+0xb82921] LibraryIntrinsic::generate(JVMState*)+0x161
        V [libjvm.dylib+0x625c66] Parse::do_call()+0xb36
        V [libjvm.dylib+0xdf488a] Parse::do_one_bytecode()+0x543a
        V [libjvm.dylib+0xde112d] Parse::do_one_block()+0x4bd
        V [libjvm.dylib+0xddfc13] Parse::do_all_blocks()+0x3d3
        V [libjvm.dylib+0xddc636] Parse::Parse(JVMState*, ciMethod*, float)+0xe76
        V [libjvm.dylib+0xde077f] Parse::Parse(JVMState*, ciMethod*, float)+0x2f
        V [libjvm.dylib+0x3d20f5] ParseGenerator::generate(JVMState*)+0xf5
        V [libjvm.dylib+0x625c66] Parse::do_call()+0xb36
        V [libjvm.dylib+0xdf488a] Parse::do_one_bytecode()+0x543a
        V [libjvm.dylib+0xde112d] Parse::do_one_block()+0x4bd
        V [libjvm.dylib+0xddfc13] Parse::do_all_blocks()+0x3d3
        V [libjvm.dylib+0xddc636] Parse::Parse(JVMState*, ciMethod*, float)+0xe76
        V [libjvm.dylib+0xde077f] Parse::Parse(JVMState*, ciMethod*, float)+0x2f
        V [libjvm.dylib+0x3d20f5] ParseGenerator::generate(JVMState*)+0xf5
        V [libjvm.dylib+0x4eaef9] Compile::Compile(ciEnv*, ciMethod*, int, bool, bool, bool, bool, DirectiveSet*)+0xbe9
        V [libjvm.dylib+0x4ee6ff] Compile::Compile(ciEnv*, ciMethod*, int, bool, bool, bool, bool, DirectiveSet*)+0x9f
        V [libjvm.dylib+0x3cff65] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x185
        V [libjvm.dylib+0x5080bc] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x98c
        V [libjvm.dylib+0x507581] CompileBroker::compiler_thread_loop()+0x381
        V [libjvm.dylib+0x106e2e8] compiler_thread_entry(JavaThread*, Thread*)+0x58
        V [libjvm.dylib+0x106ecd7] JavaThread::thread_main_inner()+0x147
        V [libjvm.dylib+0x106e837] JavaThread::run()+0x1d7
        V [libjvm.dylib+0x106a42e] Thread::call_run()+0x14e
        V [libjvm.dylib+0xda7b2f] thread_native_entry(Thread*)+0x13f
        C [libsystem_pthread.dylib+0x5d36] _pthread_start+0x7d
        C [libsystem_pthread.dylib+0x258f] thread_start+0xf
        ```

        # Reproduce

        Run the following program with:
            java -XX:-TieredCompilation -Xbatch -Xcomp -XX:CompileOnly=UnsafeAccessCompileTest::test UnsafeAccessCompileTest
        ```
        import java.lang.reflect.Field;
        import sun.misc.Unsafe;

        public class UnsafeAccessCompileTest {

            private static Unsafe initUnsafe() {
                try {
                    // Fast path when we are trusted.
                    return Unsafe.getUnsafe();
                } catch (SecurityException se) {
                    // Slow path when we are not trusted.
                    try {
                        Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
                        theUnsafe.setAccessible(true);
                        return (Unsafe) theUnsafe.get(Unsafe.class);
                    } catch (Exception e) {
                        throw new RuntimeException("exception while trying to get Unsafe", e);
                    }
                }
            }

            private static final Unsafe UNSAFE = initUnsafe();
            private static short onHeapMemory = (short)0x0102;
            private static final Object onHeapMemoryBase;
            private static final long onHeapMemoryOffset;

            static {
                try {
                    Field staticField = UnsafeAccessCompileTest.class.getDeclaredField("onHeapMemory");
                    onHeapMemoryBase = UNSAFE.staticFieldBase(staticField);
                    onHeapMemoryOffset = UNSAFE.staticFieldOffset(staticField);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }

            public static byte test() {
                return UNSAFE.getByte(onHeapMemoryBase, onHeapMemoryOffset + 1);
            }

           public static void main(String[] args) {
               System.out.println(test());
           }
        }
        ```

              jiefu Jie Fu
              jiefu Jie Fu
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: