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

All MutexLocker usages need to be bound to ensure expected destructor semantics

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.1
    • 1.0
    • hotspot
    • fcs
    • generic
    • generic


      This appears to be an issue only with the HotSpot port to SPARC/Solaris
      - I was unable to locate any instances of this in the x86/Win32 workspace.

      Consider the following code :-

      {
         MutexLocker(Terminator_lock);

         // do Something

         // end of block
      }

      Notice that MutexLocker is not bound to a variable - not sure how the
      C++ standard handles this but the C++ compilers seem too.

      With the SPARCworks compiler the constructor runs at the begining
      of the block and the destructor runs at the end of the block as
      expected.

      With the GNU g++ compiler the constructor runs followed immediately
      by the destructor - this means the mutex is not held during
      execution of the block leading to undefined behaviour.

      A licensee has reported a problem in WatcherThread::watcher_main
      (thread.cpp) where a MutexLockerEx object is used without it being
      bound to a variable - this means the mutex does not behave as
      expected. This is not an issue for the x86/Win32 workspace because
      it used a MutexLock that is bound to a variable.

            rschmidtsunw Rene Schmidt (Inactive)
            alanb Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: