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

Lack of synchronization in coding.cpp:init()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4
    • None
    • 7u80, 8
    • core-libs
    • None

    Description

      Method jdk8u-dev/jdk/src/share/native/com/sun/java/util/jar/pack/coding.cpp coding::init()
      isn't properly synchronized, in concurrent environment it could lead to exceptions or to unpredictable behavior.


      The following exception was observed during JPRT test run:
      java.lang.RuntimeException: java.lang.RuntimeException: java.io.IOException: assert failed: !(isFullRange | isSigned | isSubrange)

           at DefaultTimeZoneTest$1.run(DefaultTimeZoneTest.java:115)
      Caused by: java.lang.RuntimeException: java.io.IOException: assert failed: !(isFullRange | isSigned | isSubrange)

           at DefaultTimeZoneTest$UnpackAction.run(DefaultTimeZoneTest.java:90)
           at DefaultTimeZoneTest$1.run(DefaultTimeZoneTest.java:113)
      Caused by: java.io.IOException: assert failed: !(isFullRange | isSigned | isSubrange)

           at com.sun.java.util.jar.pack.NativeUnpack.start(Native Method)
           at com.sun.java.util.jar.pack.NativeUnpack.run(NativeUnpack.java:198)
           at com.sun.java.util.jar.pack.NativeUnpack.run(NativeUnpack.java:247)
           at com.sun.java.util.jar.pack.UnpackerImpl.unpack(UnpackerImpl.java:138)
           at com.sun.java.util.jar.pack.UnpackerImpl.unpack(UnpackerImpl.java:174)
           at DefaultTimeZoneTest$UnpackAction.run(DefaultTimeZoneTest.java:88)
           ... 1 more

      It can be thrown only from one place:
      http://ipw83120.uk.oracle.com:8080/source/xref/jdk8u-dev/jdk/src/share/native/com/sun/java/util/jar/pack/coding.cpp#130

      The following call chain leads to it:

      java NativeUnpack ->
      jdk8u-dev/jdk/src/share/native/com/sun/java/util/jar/pack/jni.cpp#Java_com_sun_java_util_jar_pack_NativeUnpack_start
      http://ipw83120.uk.oracle.com:8080/source/xref/jdk8u-dev/jdk/src/share/native/com/sun/java/util/jar/pack/jni.cpp
          ->
      jdk8u-dev/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp
      http://ipw83120.uk.oracle.com:8080/source/xref/jdk8u-dev/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp
          ->
          coding::findBySpec
      http://ipw83120.uk.oracle.com:8080/source/xref/jdk8u-dev/jdk/src/share/native/com/sun/java/util/jar/pack/coding.h
      http://ipw83120.uk.oracle.com:8080/source/xref/jdk8u-dev/jdk/src/share/native/com/sun/java/util/jar/pack/coding.cpp
          ->
          at the end we get to:
      http://ipw83120.uk.oracle.com:8080/source/xref/jdk8u-dev/jdk/src/share/native/com/sun/java/util/jar/pack/coding.cpp#72

      Exception happens due lack of synchronization in coding::init, it is assumed to be invoked only once.
      At very beginning of method you can find:
      >> if (umax > 0) return this; // already done
      and at the end:
      // do this last, to reduce MT exposure (should have a membar too)
      139 this->umax = this_umax;

      Attachments

        Issue Links

          Activity

            People

              mcherkas Mikhail Cherkasov (Inactive)
              mcherkas Mikhail Cherkasov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: