Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-12106

Double-Checked Locking issue in ExpressionManager

    XMLWordPrintable

Details

    • Bug Report
    • Resolution: Fixed
    • L3 - Default
    • 7.14.0, 7.14.0-alpha2
    • 7.13.0
    • engine
    • None

    Description

      I spotted this while going through the code of Camunda Engine. In ExpressionManager, there is piece of code following a famous pattern for lazy initialization:

        protected ELResolver getCachedElResolver() {
          if (elResolver == null) {
            synchronized(this) {
              if (elResolver == null) {
                elResolver = createElResolver();
              }
            }
          }
      
          return elResolver;
        }
      

      Problems is:

      In short: elResolver is not volatile.

      More details: What could happen is that elResolver can be not fully initialized when read by other threads. Of course, such issue is difficult to detect, especially because most of servers run with x86 CPUs that have a TSO memory model so it cannot happen but can occur with other architectures (e.g PowerPC).

      Solution: make it volatile. More information about this kind of issue https://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html

      I can raise a PR for that one if needed.

       

      Cheers,

      Paul

      mgm-controller-panel

        This is the controller panel for Smart Panels app

        Attachments

          Activity

            People

              thorben.lindhauer Thorben Lindhauer
              paulbares Paul Bares
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Salesforce