JDK-6433572 : synchronized methods with jsr's not unlocked correctly
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 6
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_9
  • CPU: sparc
  • Submitted: 2006-06-02
  • Updated: 2010-04-02
  • Resolved: 2006-06-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b88Fixed
Related Reports
Relates :  
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) {
        }
    }
}

Comments
SUGGESTED FIX http://analemma.sfbay.sun.com/net/prt-archiver.sfbay/data/archived_workspaces/main/c2_baseline/2006/20060605182142.never.sux/workspace/webrevs/webrev-2006.06.05/index.html
06-06-2006

EVALUATION The exception edge for the synthetic handler must be explicitly handled.
02-06-2006