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

Zero VM crashes when handling dynamic constant

    XMLWordPrintable

Details

    • b13
    • generic
    • generic

    Backports

      Description

        Test case:
        super public class DynamicConstantHelper
            version 55:0
        {

        static Method getDoubleConstant:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Object;I)D"
            stack 2 locals 4
        {
            dconst_0;
            dreturn;
        }

        static varargs Method getIntConstant:"(Ljava/lang/invoke/MethodHandles$Lookup;[Ljava/lang/Object;)I"
            stack 1 locals 2
        {
            ldc int 6;
            ireturn;
        }

        public static Method "testDoubleConstantDynamic":"()V"
            stack 4 locals 1
        {
            ldc2_w Dynamic REF_invokeStatic:
                    DynamicConstantHelper.getDoubleConstant:
                    "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Object;I)D":constDynDouble:"D" int 0;
            getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
            ldc String "testDoubleConstantDynamic: PASSED";
            invokevirtual Method java/io/PrintStream.println:"(Ljava/lang/String;)V";
            return;
        }

        public static Method "testIntConstantDynamic":"()V"
            stack 4 locals 1
        {
            ldc_w Dynamic REF_invokeStatic:
                    DynamicConstantHelper.getIntConstant:
                    "(Ljava/lang/invoke/MethodHandles$Lookup;[Ljava/lang/Object;)I":constantdynamic:"I";
            getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
            ldc String "testIntConstantDynamic: PASSED";
            invokevirtual Method java/io/PrintStream.println:"(Ljava/lang/String;)V";
            return;
        }
        }

        Error message:
        #
        # A fatal error has been detected by the Java Runtime Environment:
        #
        # Internal Error (bytecodeInterpreter.cpp:2406), pid=16603, tid=16615
        # Error: ShouldNotReachHere()
        #
        # JRE version: OpenJDK Runtime Environment (15.0) (build 15-internal+0-adhoc.yangfei.openjdk-jdk)
        # Java VM: OpenJDK 64-Bit Zero VM (15-internal+0-adhoc.yangfei.openjdk-jdk, interpreted mode, serial gc, linux-amd64)
        # Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %d %P" (or dumping to /home/yangfei/openjdk
        -jdk/JTwork/scratch/core.16603)
        #
        # If you would like to submit a bug report, please visit:
        # https://bugreport.java.com/bugreport/crash.jsp
        #

        Proposed fix:

        diff -r 1c7da538f065 src/hotspot/share/interpreter/bytecodeInterpreter.cpp
        --- a/src/hotspot/share/interpreter/bytecodeInterpreter.cpp Tue Feb 25 10:34:33 2020 +0800
        +++ b/src/hotspot/share/interpreter/bytecodeInterpreter.cpp Tue Feb 25 18:17:26 2020 +0800
        @@ -1,5 +1,5 @@
         /*
        - * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
        + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
          * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
          *
          * This code is free software; you can redistribute it and/or modify it
        @@ -2347,11 +2347,8 @@

                   case JVM_CONSTANT_Dynamic:
                     {
        - oop result = constants->resolved_references()->obj_at(index);
        - if (result == NULL) {
        - CALL_VM(InterpreterRuntime::resolve_ldc(THREAD, (Bytecodes::Code) opcode), handle_exception);
        - result = THREAD->vm_result();
        - }
        + CALL_VM(InterpreterRuntime::resolve_ldc(THREAD, (Bytecodes::Code) opcode), handle_exception);
        + oop result = THREAD->vm_result();
                       VERIFY_OOP(result);

                       jvalue value;
        @@ -2391,11 +2388,8 @@

                   case JVM_CONSTANT_Dynamic:
                     {
        - oop result = constants->resolved_references()->obj_at(index);
        - if (result == NULL) {
        - CALL_VM(InterpreterRuntime::resolve_ldc(THREAD, (Bytecodes::Code) opcode), handle_exception);
        - result = THREAD->vm_result();
        - }
        + CALL_VM(InterpreterRuntime::resolve_ldc(THREAD, (Bytecodes::Code) opcode), handle_exception);
        + oop result = THREAD->vm_result();
                       VERIFY_OOP(result);

        Attachments

          Issue Links

            Activity

              People

                fyang Fei Yang
                fyang Fei Yang
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: