This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 120874 - IDE hangs at startup with Services tab enabled
Summary: IDE hangs at startup with Services tab enabled
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Window System (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: David Simonek
URL:
Keywords: RANDOM, THREAD
Depends on:
Blocks:
 
Reported: 2007-11-01 18:18 UTC by John Baker
Modified: 2008-12-22 10:49 UTC (History)
7 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
thread dumps (58.68 KB, text/plain)
2007-11-01 18:18 UTC, John Baker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Baker 2007-11-01 18:18:09 UTC
At IDE startup, with the Services tab left in focus and a visualweb project left open from the previous IDE shutdown ,
There is a deadlock and IDE cannot start

Note, the start page is the page in focus at startup but it's possible other pages from visualweb projects are loading

See attached thread dumps
Comment 1 John Baker 2007-11-01 18:18:48 UTC
Created attachment 52296 [details]
thread dumps
Comment 2 John Baker 2007-11-01 18:31:28 UTC
The deadlock doesn't occur for every startup, even for the same IDE state at shutdown.
Comment 3 Vitezslav Stejskal 2007-11-01 22:19:38 UTC
I'm not really sure what is wrong. IMO the potential of deadlock in a situation like this has there been since 18 Nov
2003 when TabbedAdapter was changed to fire its state changed under AWTTreeLock. The deadlock is between AWT thread
which holds AWTTreeLock and tries to create a JsfTopComponent, which in turn tries to load its toolbar and ends up
waiting for FolderInstance RP thread. The FolderInstance is at the same time trying to load AnnotationTypes that for
some reason create JSeparator, which as a swing component needs AWTTreeLock, ending up in deadlock.

I'm reassigning this to core/windows for their evaluation. Hopefully somebody will come up with some clever idea how to
prevent this situation. Thanks
Comment 4 David Simonek 2007-11-02 10:04:57 UTC
TabbedAdapter is part of winsys and winsys strictly operates through EQ thread with its clients, similarly like Swing.
So TabbedAdapter firing in EQ seems okay to me from winsys point of view.

IMHO, loading AnnotationTypes shouldn't wait for AWT lock, that seems bad to me. But how to achieve that? I don't know.

Another possibility would be for visualweb/jsf to not wait on toolbar to get loaded, but attach some listener when
loading is finished (if that's possible, I don't know).

Passing to visualweb, ccing AnnotationTypes authors and thread experts.
Comment 5 Vitezslav Stejskal 2007-11-02 10:33:49 UTC
Just for the record, the problem is not that TabbedAdapter fires on EQ, but that it fires when holding AWTTreeLock. As a
general rule of thumb events should never be fired when holding locks. Nobody knows who can listen and what other locks
they may need to acquire. At the same time I understands that the locking in TabbedAdapter was done to prevent extensive
repaints and it's been in place for ages, so it's really hard to blame.
Comment 6 Jaroslav Tulach 2007-11-02 10:36:36 UTC
#1 TabbedAdaptor is OK to fire changes in AWT event thread
#2 TabbedAdaptor is wrong to fire changes while holding AWT tree lock

In general it is recommened to never deliver any events to listeners while holding a lock. Listeners are foreign and 
unknown code and as such subject to deadlock. That is why I think that this deadlock is TabbedAdaptor fault at

        at org.netbeans.core.windows.view.ui.tabcontrol.TabbedAdapter.fireStateChanged(TabbedAdapter.java:441)
        - locked <0x08abce90> (a java.awt.Component$AWTTreeLock)

However I inspected the source code, and there is a note about "holding of AWT tree lock" speeding up some redrawing. 
Looks like we will have to choose between speed and deadlocks (or correctness).
Comment 7 David Simonek 2007-11-02 11:26:28 UTC
OK, thanks for an explanation, passing back to me. I'll remove tree lock, hang is more serious then redrawing speed and
moreover in JDK 1.6 and further it may not be valid, or at least we don't have the speedup measured and confirmed AFAIK.
If redrawing speed turns to be a problem, we should consider another techniques to speed it up.
Comment 8 David Simonek 2007-11-05 13:12:24 UTC
tree lock removed:

Checking in TabbedAdapter.java;
/cvs/core/windows/src/org/netbeans/core/windows/view/ui/tabcontrol/TabbedAdapter.java,v  <--  TabbedAdapter.java
new revision: 1.41; previous revision: 1.40
done

I tested both on Linux and Win, under JDK 1.5 and 1.6 and I couldn't reproduce multiple redrawing when tree lock was
removed, even with J-Dawt.nativeDoubleBuffering=true set. Either is redrawing fixed in newer JDKs or impact is so low
that it's not visible anymore.
Comment 9 Jesse Glick 2007-11-05 14:53:32 UTC
Could probably also have been fixed in visualweb, though it is hard to say what other code might have been affected.
Root problem to me looks like creation of JSeparator in FolderInstance which grabs AWT lock.
Comment 10 Petr Chytil 2007-11-22 13:42:46 UTC
verified in:

Product Version: NetBeans IDE 6.0 RC2 (Build 200711201000)
Java: 1.6.0_03; Java HotSpot(TM) Client VM 1.6.0_03-b05
System: Linux version 2.6.22-14-generic running on i386; UTF-8; en_US (nb)
Userdir: /home/petr/.netbeans/6.0rc2