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

Math.random() / Math.initRNG() uses "double checked locking"

XMLWordPrintable

    • b106
    • x86
    • linux
    • Not verified

      FULL PRODUCT VERSION :
      java version "1.6.0-rc"
      Java(TM) SE Runtime Environment (build 1.6.0-rc-b95)
      Java HotSpot(TM) Server VM (build 1.6.0-rc-b95, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Linux xxxxxx 2.6.16 #2 SMP Mon Mar 27 17:30:45 CEST 2006 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      Math.random() and Math.initRNG() uses DCL (double checked locking) on " private static Random randomNumberGenerator".

      Breaks in a multi processor environment, resulting in a NPE.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Init field "private static Random randomNumberGenerator" in static initializer

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Spurius NullPointerException

      REPRODUCIBILITY :
      This bug can be reproduced rarely.

      CUSTOMER SUBMITTED WORKAROUND :
      Do not use Math.random

            bpb Brian Burkhalter
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: