public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* java/1110: gcj does not handle synchronized methods properly
@ 2000-12-20 12:07 gback
  0 siblings, 0 replies; only message in thread
From: gback @ 2000-12-20 12:07 UTC (permalink / raw)
  To: java-gnats

>Number:         1110
>Category:       java
>Synopsis:       gcj does not handle synchronized methods properly
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    apbianco
>State:          closed
>Class:          mistaken
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 20 12:06:05 PST 2000
>Closed-Date:    Tue Nov 16 17:33:51 PST 1999
>Last-Modified:  Tue Nov 16 17:40:00 PST 1999
>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:

Formerly PR gcj/104

State-Changed-From-To: open->closed
State-Changed-By: bryce
State-Changed-When: Tue Nov 16 17:33:51 1999
State-Changed-Why:
    It works fine for me, and Godmar reports that the problem 
    was due to a mis-installed libgcj.

From: bryce@albatross.co.nz
To: apbianco@cygnus.com, gback@cs.utah.edu, java-gnats@sourceware.cygnus.com
Cc:  
Subject: Re: gcj/104
Date: 17 Nov 1999 01:33:51 -0000

 Synopsis: gcj does not handle synchronized methods properly
 
 State-Changed-From-To: open->closed
 State-Changed-By: bryce
 State-Changed-When: Tue Nov 16 17:33:51 1999
 State-Changed-Why:
     It works fine for me, and Godmar reports that the problem 
     was due to a mis-installed libgcj.
 
 http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?cmd=view&database=java&pr=104
>Unformatted:



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-12-20 12:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-20 12:07 java/1110: gcj does not handle synchronized methods properly gback

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).