Uploaded image for project: 'Commons BCEL'
  1. Commons BCEL
  2. BCEL-267

Race conditions on static fields in BranchHandle and InstructionHandle

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.2
    • Fix Version/s: 6.3.1
    • Component/s: Main
    • Labels:
      None
    • Flags:
      Patch
    • Severity:
      normal

      Description

      I have observed race conditions causing NullPointerException like this

      java.lang.NullPointerException
              at org.apache.bcel.generic.InstructionList.getInstructionHandles(InstructionList.java:1021)
              at org.apache.bcel.generic.InstructionList.findHandle(InstructionList.java:141)
              at org.apache.bcel.generic.MethodGen.<init>(MethodGen.java:194)
      

      In the debugger I could verify that concurrent access to the fields BranchHandle.bh_list or InstructionHandle.ih_list can cause corruption of those lists.

      I succeeded to make the exception less frequent by adding synchronized blocks, but still the exception could be observed. I concluded that for safe protection the fields would need to be made volatile, which in the end might actually defeat their original purpose of optimization.

      I have since then run with a patched version of BCEL, where those static fields were simply removed and new Handles were created on every request. This variant finally was free of the race condition.

      Seeing activity towards a 6.0 release, I'd appreciate if this change could be incorporated.

      The original bug tracking my experiments can be found in Eclipse bugzilla: https://bugs.eclipse.org/344350

      The modified classes (based on 5.2) can be found here:

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                sherrmann Stephan Herrmann
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m