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

Loop Predication should not hoist range checks with trap on success projection by negating their condition

XMLWordPrintable

    • b01
    • b26
    • x86_64
    • generic

        ADDITIONAL SYSTEM INFORMATION :
        Ubuntu 22.04 / JDK 11.0.19 (but also 17.0.7)

        A DESCRIPTION OF THE PROBLEM :
        Since the docker image we use to build our application (maven:3.9.1-eclipse-temurin-11-focal) is based on the JDK version 11.0.19, one of our Unit Test makes the JVM crash systematically.
        With the image based on jdk 11.0.18 we do not encounter the problem.

        I crashes with the following message:
        #
        # A fatal error has been detected by the Java Runtime Environment:
        #
        # Internal Error (macroAssembler_x86.cpp:864), pid=51663, tid=51664
        # fatal error: DEBUG MESSAGE: duplicated predicate failed which is impossible
        #
        # JRE version: OpenJDK Runtime Environment Temurin-17.0.7+7 (17.0.7+7) (build 17.0.7+7)
        # Java VM: OpenJDK 64-Bit Server VM Temurin-17.0.7+7 (17.0.7+7, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
        # Problematic frame:
        # V [libjvm.so+0xafec21] MacroAssembler::debug64(char*, long, long*)+0x41
        #
        # 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/xxxxxxxx/tmp/core.51663)
        #
        # An error report file with more information is saved as:
        # /tmp/hs_err_pid51663.log
        Compiled method (c2) 139 288 4 java.util.GregorianCalendar::computeTime (976 bytes)
         total in heap [0x00007f6100ed7f90,0x00007f6100ed8680] = 1776
         relocation [0x00007f6100ed80f0,0x00007f6100ed8120] = 48
         main code [0x00007f6100ed8120,0x00007f6100ed8460] = 832
         stub code [0x00007f6100ed8460,0x00007f6100ed8478] = 24
         metadata [0x00007f6100ed8478,0x00007f6100ed84e0] = 104
         scopes data [0x00007f6100ed84e0,0x00007f6100ed85a0] = 192
         scopes pcs [0x00007f6100ed85a0,0x00007f6100ed8620] = 128
         dependencies [0x00007f6100ed8620,0x00007f6100ed8648] = 40
         handler table [0x00007f6100ed8648,0x00007f6100ed8660] = 24
         nul chk table [0x00007f6100ed8660,0x00007f6100ed8680] = 32
        Compiled method (c2) 141 288 4 java.util.GregorianCalendar::computeTime (976 bytes)
         total in heap [0x00007f6100ed7f90,0x00007f6100ed8680] = 1776
         relocation [0x00007f6100ed80f0,0x00007f6100ed8120] = 48
         main code [0x00007f6100ed8120,0x00007f6100ed8460] = 832
         stub code [0x00007f6100ed8460,0x00007f6100ed8478] = 24
         metadata [0x00007f6100ed8478,0x00007f6100ed84e0] = 104
         scopes data [0x00007f6100ed84e0,0x00007f6100ed85a0] = 192
         scopes pcs [0x00007f6100ed85a0,0x00007f6100ed8620] = 128
         dependencies [0x00007f6100ed8620,0x00007f6100ed8648] = 40
         handler table [0x00007f6100ed8648,0x00007f6100ed8660] = 24
         nul chk table [0x00007f6100ed8660,0x00007f6100ed8680] = 32
        #
        # If you would like to submit a bug report, please visit:
        # https://github.com/adoptium/adoptium-support/issues
        #
        fish: Job 1, '/home/xxxxxxxx/.sdkman/candidat…' terminated by signal SIGABRT (Abort)


        We managed to reproduce it with a simple use case: it happens when we create a Calendar, set lenient to false and force the HOUR_OF_DAY and the MINUTE fields to 0 then call getTime() that triggers computeTime().

        The failure occurs only after calling the method several thousands of time, this is why we think the JIT compiler has something to do with it.

        Also the problem does not happen when the -Xcomp flag is set.

        We tested it on JDK17 and the same problem occurs with the 17.0.7 version (it works fine with 17.0.6)

        REGRESSION : Last worked in version 11.0.18

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        use the test case source code below:

        javac TestCalendarJit.java
        java TestCalendarJit


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        no crash after the 100000 calls loop
        ACTUAL -
        2544
        2545
        2546
        2547
        2548
        2549
        2550
        2551
        2552
        2553
        2554
        2555
        2556
        =============== DEBUG MESSAGE: duplicated predicate failed which is impossible ================

        #
        # A fatal error has been detected by the Java Runtime Environment:
        #
        # SIGSEGV (0xb) at pc=0x00007fd3b80d97a9, pid=51869, tid=51870
        #
        # JRE version: OpenJDK Runtime Environment Temurin-11.0.19+7 (11.0.19+7) (build 11.0.19+7)
        # Java VM: OpenJDK 64-Bit Server VM Temurin-11.0.19+7 (11.0.19+7, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
        # Problematic frame:
        # J 306 c2 java.util.GregorianCalendar.computeTime()V java.base@11.0.19 (970 bytes) @ 0x00007fd3b80d97a9 [0x00007fd3b80d95c0+0x00000000000001e9]
        #
        # 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/xxxxxxxx/tmp/core.51869)
        #
        # An error report file with more information is saved as:
        # /home/xxxxxxxx/tmp/hs_err_pid51869.log
        Compiled method (c2) 193 306 4 java.util.GregorianCalendar::computeTime (970 bytes)
         total in heap [0x00007fd3b80d9410,0x00007fd3b80d9a90] = 1664
         relocation [0x00007fd3b80d9588,0x00007fd3b80d95b8] = 48
         main code [0x00007fd3b80d95c0,0x00007fd3b80d9880] = 704
         stub code [0x00007fd3b80d9880,0x00007fd3b80d9898] = 24
         metadata [0x00007fd3b80d9898,0x00007fd3b80d9900] = 104
         scopes data [0x00007fd3b80d9900,0x00007fd3b80d99c0] = 192
         scopes pcs [0x00007fd3b80d99c0,0x00007fd3b80d9a40] = 128
         dependencies [0x00007fd3b80d9a40,0x00007fd3b80d9a58] = 24
         handler table [0x00007fd3b80d9a58,0x00007fd3b80d9a70] = 24
         nul chk table [0x00007fd3b80d9a70,0x00007fd3b80d9a90] = 32
        Compiled method (c1) 194 304 3 TestCalendarJit::getDate (29 bytes)
         total in heap [0x00007fd3b0c21a10,0x00007fd3b0c22680] = 3184
         relocation [0x00007fd3b0c21b88,0x00007fd3b0c21c40] = 184
         main code [0x00007fd3b0c21c40,0x00007fd3b0c223c0] = 1920
         stub code [0x00007fd3b0c223c0,0x00007fd3b0c22450] = 144
         oops [0x00007fd3b0c22450,0x00007fd3b0c22458] = 8
         metadata [0x00007fd3b0c22458,0x00007fd3b0c224a0] = 72
         scopes data [0x00007fd3b0c224a0,0x00007fd3b0c22558] = 184
         scopes pcs [0x00007fd3b0c22558,0x00007fd3b0c22668] = 272
         dependencies [0x00007fd3b0c22668,0x00007fd3b0c22670] = 8
         nul chk table [0x00007fd3b0c22670,0x00007fd3b0c22680] = 16
        Could not load hsdis-amd64.so; library not loadable; PrintAssembly is disabled
        #
        # If you would like to submit a bug report, please visit:
        # https://github.com/adoptium/adoptium-support/issues
        #
        fish: Job 1, '/home/xxxxxxxx/.sdkman/candidat…' terminated by signal SIGABRT (Abort)


        ---------- BEGIN SOURCE ----------

        import java.util.Calendar;

        public class TestCalendarJit {

            public static void main(String[] args) {
                for (int i = 0; i < 100000; i++) {
                    System.err.println(i);
                    getDate();
                }
            }

            private static void getDate() {
                Calendar c = Calendar.getInstance();
                c.setLenient(false);
                c.set(Calendar.HOUR_OF_DAY, 0);
                c.set(Calendar.MINUTE, 0);
                c.getTime();
            }
        }

        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        the problem does not occur with the -Xcomp flag set

        FREQUENCY : occasionally


              chagedorn Christian Hagedorn
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              14 Start watching this issue

                Created:
                Updated:
                Resolved: