Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-1134

unsafe initialization in BicubicSplineInterpolatingFunction

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.3
    • Fix Version/s: 3.4
    • Labels:
      None

      Description

      The lazy initialization of the internal array of partialDerivatives in BicubicSplineInterpolatingFunction is not thread safe. If multiple threads call any of the partialDerivative functions concurrently one thread may start the initialization and others will see the array is non-null and assume it is fully initialized. If the internal array of partial derivatives was initialized in the constructor this would not be a problem.

      i.e. the following check in partialDerivative(which, x, y)
      if (partialDerivatives == null)

      { computePartialDerivatives(); }

      will start the initialization. However in computePartialDerivatives()
      partialDerivatives = new BivariateFunction[5][lastI][lastJ];

      makes it appear to other threads as the the initialization has completed when it may not have.

        Attachments

        1. MATH-1134.patch
          1 kB
          Phil Steitz

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              dscherger Derek Scherger
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: