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

(1.1) jni_AttachCurrentThread may not be thread safe on Win32

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.1.6
    • hotspot
    • x86
    • windows_nt



      Name: clC74495 Date: 06/18/98


      My configuration is the Java JRE 1.1.6 on Windows NT 4.0 Server
      using LiveSoftware JRun Servlet runner for integration into
      Microsoft Internet Information Server (IIS) 3.0. The system
      is a 300MHz Dual Pentium II PC server.

      There seems to be a problem in the function jni_AttachCurrentThread()
      in the JNI.C source file where the PrivateInfo member of the
      Java Thread object (java_thr) seems to be being written to a
      zero value by some other thread of execution. This ultimately
      leads to an Access Violation in the sysThreadSetPriority() function
      which cannot be passed a zero value for the thread id.

      The three important lines of code in jni_AttachCurrentThread()
      are the following.

      1: THREAD(java_thr)->PrivateInfo = (long)sys_thr;
      2: THREAD(java_thr)->priority = NormalPriority;
      3: threadSetPriority(java_thr, NormalPriority);

      The java_thr->obj->PrivateInfo member is set to the value
      sys_thr, but when threadSetPriority() macro is called
      only two statements later, the debugger reports that
      java_thr->obj->PrivateInfo is now zero and no longer equals
      sys_thr, which it was just set to. Because a zero value
      is passed to threadSetPriority() an Access violation occurs
      within the function sysThreadSetPriority() which is called
      by the macro.

      I have checked the assembly code around these statements
      and it seems compeletely valid.

      This bug seems to be extremely hard to reproduce and occurs
      after anywhere between 100,000 to 500,000 calls to the
      jni_AttachCurrentThread() function -- about 1 to 2 hours into
      a heavy load placed on the IIS web server. This function is
      called whenever IIS spawns a request to be serviced by the
      JRun servlet engine and our servlet. If needed, I can go into
      more detail regarding what type of load needs to be placed
      on the IIS server to reproduce this problem.

      My best guess after analyzing the problem is that some other
      thread of execution within the Java VM manipulates the
      Java thread object which results in setting it's PrivateInfo
      member to zero.

      This bug has the potential of delaying the shipment of an
      important new graphics product for Macromedia. Therefore,
      it is important that we have help from Sun to track down
      and resolve whatever problem is occuring.

      Mike Thompson
      ###@###.###
      (Review ID: 33865)
      ======================================================================

            sliangsunw Sheng Liang (Inactive)
            clucasius Carlos Lucasius (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: