From owner-freebsd-java Thu May 18 22:57:33 2000 Delivered-To: freebsd-java@freebsd.org Received: from seanreilly.com (209-9-223-139.sdsl.cais.net [209.9.223.139]) by hub.freebsd.org (Postfix) with ESMTP id 9557C37BA7B for ; Thu, 18 May 2000 22:57:24 -0700 (PDT) (envelope-from sreilly@seanreilly.com) Received: from localhost (localhost [127.0.0.1]) by seanreilly.com (8.9.3/8.9.3) with ESMTP id CAA62479; Fri, 19 May 2000 02:01:49 -0400 (EDT) (envelope-from sreilly@seanreilly.com) Date: Fri, 19 May 2000 02:01:47 -0400 (EDT) From: Sean Reilly To: Nate Williams Cc: freebsd-java@FreeBSD.ORG Subject: Re: problem in 1.1.8 In-Reply-To: <200005190425.WAA28735@nomad.yogotech.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org > "finalize" should *NEVER* be called from external threads, and is the > domain of the GC thread. Are you calling finalize by hand? Nope, I'm not calling gc or finalize anywhere in the program. > See above. How are you loading the image? Can you give a bit more > details as to what exactly the program is doing. No problem. I'd send you the complete source code but it's probably too big to be a useful example. The program first loads a GIF file to be displayed in a splash window. I use something like: Image img = toolkit.getImage(someClass.getResource(...)); to load the image. Then I create a MediaTracker, add the image to it, then do a waitForID(..) to try to fully load the image: MediaTracker tracker = new MediaTracker(this); tracker.addImage(img,0); tracker.waitForID(0); The next step is to set the window with the ImagePanel (my own simple image component) to be visible, and then go to work loading the data file for the program. That's where the problem occurs... while the data file is loading in the main thread (see the readUTF call) the image never actually gets rendered to the screen. I'm definitely not calling the X11Graphics.finalize method (in the trace below it seems to be coming from the String. class which can't be right). Is the stack getting screwed up? > > Full thread dump: > > sun.awt.AWTFinalizer.run(AWTFinalizer.java:40) > > "Image Animator 0" (TID:0x2869aab0, sys_thread_t:0x29507f00, state:MW) > > prio=3 > > sun.awt.image.ImageDecoder.close(ImageDecoder.java:163) > > Image Animator 0 is callig close and is waiting on the monitor. > > > "main" (TID:0x2866f0b0, sys_thread_t:0x8124a00, state:MW) prio=5 > > sun.awt.motif.X11Graphics.finalize(X11Graphics.java:109) > > java.lang.String.(String.java) > > java.io.DataInputStream.readUTF(DataInputStream.java) > > java.io.DataInputStream.readUTF(DataInputStream.java) > > And the main thread is calling finalize, which is weird. > > > sun.awt.image.GifImageDecoder@2869AE78/286FB0E8: owner "Image Animator > > 0" (0x29507f00, 1 entry) > > sun.awt.motif.MToolkit@286900B0/286DDD28: > > Waiting to be notified: > > "AWT-Motif" (0x294e4f00) > > java.lang.Class@28699CD0/286F5140: owner "AWT-EventQueue-0" > > (0x294a2f00, 1 entry) > > java.lang.Class@2869AE80/286FB070: owner "Image Animator 0" > > (0x29507f00, 1 entry) > > java.lang.Class@28699EB8/286F58C8: owner "main" (0x8124a00, 1 entry) > > sun.awt.AWTFinalizer@2869AFC8/286DE6B0: > > Waiting to be notified: > > "AWT-Finalizer" (0x29528f00) > > (0x29452f00): > > Waiting to be notified: > > "Async Garbage Collector" (0x29452f00) > > Interesting. Why is readObject() calling the GC? You're not making any > explicity calls to the garbage collector, are you? None at all. readObject calling gc? I don't have any readObject methods in my code nor any type of object (de)serialization. > > Registered Monitor Dump: > > Thread queue lock: > > Name and type hash table lock: > > String intern lock: > > JNI pinning lock: > > JNI global reference lock: > > BinClass lock: > > Class loading lock: owner "AWT-EventQueue-0" (0x294a2f00, 1 entry) > > Waiting to enter: > > "main" (0x8124a00) > > "Image Animator 0" (0x29507f00) > > Ahh, this is a clue. It turns out that there are races in the Java > imaging code (which is a complete mess), and you may have stumbled on > them. Sometimes moving the code around and/or adding sleeps in places > causes the races to go away. *ESPECIALLY* when dealing with object > serialization. > > You aren't using any static class locks by chance are you? Nope. Maybe some of the underlying java.* classes do? I already have a one second sleep after the setVisible on the splash window before the app starts to do its thing... taking that out doesn't seem to help. It seems like the deadlock is between something in the X11Graphics.finalize() method in the main thread and the LightweightDispatcher.dispatchEvent() method in the AWT-EventQueue-0 thread. The thing I don't understand is how the finalize method of X11Graphics is getting called in the main thread when the nothing in the stack trace up to that point ever calls it! Thanks, Sean To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message