This is the mail archive of the
java-prs@sourceware.cygnus.com
mailing list for the Java project.
gcj/104: gcj does not handle synchronized methods properly
- To: java-gnats at sourceware dot cygnus dot com
- Subject: gcj/104: gcj does not handle synchronized methods properly
- From: gback at cs dot utah dot edu
- Date: 16 Nov 1999 22:24:18 -0000
- Reply-To: gback at cs dot utah dot edu
- Resent-Cc: java-prs at sourceware dot cygnus dot com, green at cygnus dot com
- Resent-Reply-To: java-gnats@sourceware.cygnus.com, gback@cs.utah.edu
>Number: 104
>Category: gcj
>Synopsis: gcj does not handle synchronized methods properly
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: apbianco
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Nov 16 14:30:00 PST 1999
>Closed-Date:
>Last-Modified:
>Originator: Godmar Back
>Release: CVS October
>Organization:
>Environment:
RH 5.2, Linux 2.2.12, glibc 2.0.7
both gcj and libgcj configured with --enable-threads=posix
>Description:
gcj doesn't compile proper exception handling code.
>How-To-Repeat:
/**
* Test that locks taken in synchronized methods are properly unlocked
* when an exception occurs. Note that different mechanisms are used in
* compiler & interpreter.
*
* @author Godmar Back <gback@cs.utah.edu>
*/
public class TestUnlock {
synchronized void throwException() throws Exception {
throw new Exception();
}
synchronized void success() {
System.out.println("Success.");
}
public static void main(String av[]) throws Exception {
final TestUnlock me = new TestUnlock();
new Thread() {
public void run() {
try {
Thread.sleep(2000);
} catch (Exception _) { }
System.out.println("Time out. Failure.");
System.exit(-1);
}
}.start();
Thread t = new Thread() {
public void run() {
try {
me.throwException();
} catch (Exception _) {
}
}
};
t.start();
t.join();
Thread t2 = new Thread() {
public void run() {
me.success();
}
};
t2.start();
t2.join();
System.exit(0);
}
}
/* Expected Output:
Success.
*/
>Fix:
Not sure.
Wrap whole function body of a synchronized method
in try/finally?
>Release-Note:
>Audit-Trail:
>Unformatted: