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

RISC-V: Several foreign jtreg tests fail with debug build after JDK-8301818

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 21
    • 21
    • hotspot
    • None
    • b10
    • riscv
    • linux

    Backports

      Description

        1. Run foreign jtreg tests with fastdebug build on linux-riscv64 platform:
          $ make run-test-only TEST="jdk_foreign" JTREG="TIMEOUT_FACTOR=24"

        --------------------------------------------------
        TEST: java/foreign/TestDowncallScope.java
        TEST JDK: /home/fyang/openjdk-jdk/build/linux-riscv64-server-fastdebug/images/jdk

        ......

        test TestDowncallScope.testDowncall(9928, "f16_P_PSS_DP", NON_VOID, [POINTER, STRUCT, STRUCT], [DOUBLE, POINTER]): success
        test TestDowncallScope.testDowncall(9945, "f16_P_PSS_IPI", NON_VOID, [POINTER, STRUCT, STRUCT], [INT, POINTER, INT]): success
        test TestDowncallScope.testDowncall(9962, "f16_P_PSS_FPF", NON_VOID, [POINTER, STRUCT, STRUCT], [FLOAT, POINTER, FLOAT]): success
        test TestDowncallScope.testDowncall(9979, "f16_P_PSS_DPD", NON_VOID, [POINTER, STRUCT, STRUCT], [DOUBLE, POINTER, DOUBLE]): success
        test TestDowncallScope.testDowncall(9996, "f16_P_PSS_PPP", NON_VOID, [POINTER, STRUCT, STRUCT], [POINTER, POINTER, POINTER]): success
        test TestDowncallScope.testDowncall(10013, "f16_S_SII_PI", NON_VOID, [STRUCT, INT, INT], [POINTER, INT]): success
        #
        # A fatal error has been detected by the Java Runtime Environment:
        #
        # Internal Error (0xe0000000), pid=464665, tid=464685
        # stop: must be a primitive array
        #
        # JRE version: OpenJDK Runtime Environment (21.0) (fastdebug build 21-internal-adhoc.fyang.openjdk-jdk)
        # Java VM: OpenJDK 64-Bit Server VM (fastdebug 21-internal-adhoc.fyang.openjdk-jdk, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-riscv64)
        # Problematic frame:
        # v ~StubRoutines::generic_arraycopy 0x0000003fa3de0df4
        #
        # 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 -- %E" (or dumping to /home/fyang/openjdk-jdk/build/linux-riscv64-server-fastdebug/test-support/jtreg_test_jdk_jdk_foreign/scratch/0/core.464665)
        #
        # An error report file with more information is saved as:
        # /home/fyang/openjdk-jdk/build/linux-riscv64-server-fastdebug/test-support/jtreg_test_jdk_jdk_foreign/scratch/0/hs_err_pid464665.log
        [73.630s][warning][os] Loading hsdis library failed
        #
        # If you would like to submit a bug report, please visit:
        # https://bugreport.java.com/bugreport/crash.jsp
        #

        ......

        --------------------------------------------------

        2. Some initial analysis:
        This problem only triggers when using debug build to run foreign jtreg tests.
        JDK-8301818 made following code changes in function generate_generic_copy [1]:

        ```
            // At this point, it is known to be a typeArray (array_tag 0x3).
         #ifdef ASSERT
             {
               BLOCK_COMMENT("assert primitive array {");
               Label L;
        - __ mvw(t1, Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift);
        + __ mv(t1, Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift);
               __ bge(lh, t1, L);
               __ stop("must be a primitive array");
               __ bind(L);
               BLOCK_COMMENT("} assert primitive array done");
            }
         #endif
        ```

        Notably, Klass::_lh_array_tag_type_value is of type unsigned int:
        ```
          static const unsigned int _lh_array_tag_type_value = 0Xffffffff;
          static const int _lh_array_tag_shift = BitsPerInt - _lh_array_tag_bits;
          static const int _lh_array_tag_bits = 2;
        ```
        So Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift would be 0xc0000000 of type unsigned int.

        Previously, 'mvw' function would sign-extend this value into 64-bit 0xffffffffc0000000 since we want to do 64-bit signed compare and branch with 'bge' instruction next.
        ```
          template<typename T, ENABLE_IF(std::is_integral<T>::value)>
          inline void mv(Register Rd, T o) { li(Rd, (int64_t)o); }

          inline void mvw(Register Rd, int32_t imm32) { mv(Rd, imm32); }
        ```

        But this is not the case when changed to use 'mv' with type unsigned int. So I think this changes the behaviour.
        Simple fix would be adding an explict int32_t type conversion for this value, like:
        __ mv(t1, (int32_t)(Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift));

        [1] https://github.com/openjdk/jdk/commit/c04a982eb47170f3c613617179fca012bb4d40ae

        Attachments

          Issue Links

            Activity

              People

                fjiang Feilong Jiang
                fyang Fei Yang
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: