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

java.util.GregorianCalendar.computeTime() crashes with lenient=false

XMLWordPrintable

      # A fatal error has been detected by the Java Runtime Environment:
      #
      # EXCEPTION_PRIV_INSTRUCTION (0xc0000096) at pc=0x000002405742ccc7, pid=2372, tid=12412
      #
      # JRE version: OpenJDK Runtime Environment Corretto-11.0.19.7.1 (11.0.19+7) (build 11.0.19+7-LTS)
      # Java VM: OpenJDK 64-Bit Server VM Corretto-11.0.19.7.1 (11.0.19+7-LTS, mixed mode, tiered, compressed oops, g1 gc, windows-amd64)
      # Problematic frame:
      # J 435 c2 java.util.GregorianCalendar.computeTime()V java.base@11.0.19 (970 bytes) @ 0x000002405742ccc7 [0x000002405742c340+0x0000000000000987]
      #
      # No core dump will be written. Minidumps are not enabled by default on client versions of Windows
      #
      # If you would like to submit a bug report, please visit:
      # https://github.com/corretto/corretto-11/issues/
      #

      --------------- S U M M A R Y ------------

      Command Line: -Dfile.encoding=windows-1252 test.Datetest

      Host: Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz, 4 cores, 7G, Windows 10 , 64 bit Build 19041 (10.0.19041.2913)
      Time: Thu May 11 13:38:36 2023 Mitteleuropäische Sommerzeit elapsed time: 0.335004 seconds (0d 0h 0m 0s)

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

      Current thread (0x00000240471ba800): JavaThread "main" [_thread_in_Java, id=12412, stack(0x0000008125a00000,0x0000008125b00000)]

      Stack: [0x0000008125a00000,0x0000008125b00000], sp=0x0000008125afed60, free space=1019k
      Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
      C 0x000002405742ccc7



      ADDITIONAL SYSTEM INFORMATION :
       Linux and Windows 64Bit with Java 11.0.19 Corretto and Adoptium


      A DESCRIPTION OF THE PROBLEM :
      Core Dump when using GregorianCalen


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Using the class below on my machine results in a crashed JVM in ~90% of cases.
      When starting with lenient=false it always crashed (~12 tries)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Should not crash
      ACTUAL -
      crashes

      ---------- BEGIN SOURCE ----------
      import java.util.Calendar;
      import java.util.Date;
      import java.util.stream.IntStream;

      public class Datetest
      {
        public static void main( String[] args )

        {

      Datetest.crashMe(false);
      Datetest.crashMe(true);

        }

        public static void crashMe(boolean crash) {
      IntStream.range( 0, 8000 ).forEach( i -> {

      Calendar timespan = Calendar.getInstance();
      timespan = removeTime( new Date(), crash );
      timespan.getTime();

      if (i%10==0) {
      System.out.println( "Crash: "+crash+ " Iteration: " + i + " / " + timespan.toString() );
      }

      } );

        }
       

        public static Calendar removeTime( Date date, boolean crash_me )
        {

          Calendar calendar = Calendar.getInstance();
          if (crash_me) {
           calendar.setLenient( false );
          }
          calendar.setTime( date );
          calendar = Datetest.removeTime( calendar );
          return calendar;

        }


        public static Calendar removeTime( Calendar calendar )

        {

          calendar.set( Calendar.HOUR_OF_DAY, 0 );

          calendar.set( Calendar.MINUTE, 0 );

          calendar.set( Calendar.SECOND, 0 );

          calendar.set( Calendar.MILLISECOND, 0 );

          return calendar;

        }

       

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Never crashes with lenient=true
      I could also not reproduce this with 32bit-Build (5 tries)

      FREQUENCY : often


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

              Created:
              Updated:
              Resolved: