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

synchronized methods with jsr's not unlocked correctly

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 6
    • Fix Version/s: 6
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b88
    • CPU:
      sparc
    • OS:
      solaris_9

      Description

      6320351 included changes to the way synchronized methods were unlocked to make the exception paths and jvmpi support simpler to implement. This broke the unlocking of synchonized methods when exceptions are thrown inside jsrs because the synthetic block handling the unlocking wasn't seen when processing exception edges while parsing jsrs. Here's a test case for this which must be compiled with a javac that uses jsr/ret for finally blocks.

      public class SyncJSR {
          private int count = 0;
          private int[] ia = new int[1];

          public synchronized void calc() {
              try {
                  count++;
              } finally {
                  // always throws a NullPointerException
                  ia[0] = 1;
              }
          }

          public void calcCatch() {
              try {
                  calc();
              } catch (NullPointerException ex) {
                  // catch the exception thrown in calc()
              }
          }

          public static void main(String[] args) {
              SyncJSR obj = new SyncJSR();

              for (int i = 0; i < 200000; i++) {
                  obj.calcCatch();
              }
              obj.ia = null;
              obj.calcCatch();

              try {
                  // Usually, this crashes the VM if the object was not unlocked correctly
                  obj.wait(1000);
              } catch (Exception ex) {
              }
          }
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              never Tom Rodriguez
              Reporter:
              never Tom Rodriguez
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: