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 29993 - Start up deadlock
Summary: Start up deadlock
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 3.x
Hardware: PC Linux
: P2 blocker (vote)
Assignee: mslama
URL:
Keywords: THREAD
Depends on:
Blocks:
 
Reported: 2003-01-13 11:36 UTC by _ pkuzel
Modified: 2008-12-22 21:47 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
The deadlock (6.20 KB, text/plain)
2003-01-13 11:36 UTC, _ pkuzel
Details
The deadlock (6.20 KB, text/plain)
2003-01-13 12:54 UTC, _ pkuzel
Details
Modality vs. blocking semantics test (1017 bytes, text/x-java)
2003-01-24 09:16 UTC, _ pkuzel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description _ pkuzel 2003-01-13 11:36:12 UTC
If recent selected node is one from Jini browser
children then it deadlocks IDE during startup.

I think that it's NbPresenter error as
setVisible() should be thread safe method.
(Moreover it's called in non modal mode).
Comment 1 _ pkuzel 2003-01-13 11:36:39 UTC
Created attachment 8544 [details]
The deadlock
Comment 2 _ pkuzel 2003-01-13 12:54:16 UTC
Created attachment 8545 [details]
The deadlock
Comment 3 _ pkuzel 2003-01-16 07:25:31 UTC
Discussed with Marek Slama and concluded that a dialog returned by
TopManager,createDialog() should have thread safe setVisible(true)
implementation.
Comment 4 mslama 2003-01-23 11:30:21 UTC
Two things:
1.NbPresenter.show() is safe because it is called from AWT thread.
However it must be synchronous so invokeAndWait() is used.
2.From thread dump you provided is not clear where deadlock exactly is
ie. where (probably) nodes are locked.

The problem is caused by calling NbPresenter.show() from some node
lock which is held at the same time by AWT thread. It seems
FolderChildren.findChild() is waiting.

From thread dump the only solution I see is to avoid calling
NbPresenter.show() from Default Request Processor but use
invokeLater(). In AWT thread tree in ExplorerPanel is expanded and it
calls findChild() synchronously and it cannot be split. Any other idea?
Comment 5 mslama 2003-01-23 11:40:43 UTC
Sorry:
The problem is caused by calling NbPresenter.show() from some node
lock which is held at the same time by AWT thread. It seems
FolderChildren.findChild() is waiting.

Should be:
The problem is caused by calling NbPresenter.show() from findChild()
when findChild() helds lock which is AWT thread waiting for.


Comment 6 mslama 2003-01-23 11:48:03 UTC
Fixed comment:

When NbPresenter.show() is not called from AWT thread it uses
invokeAndWait() to call super.show() in AWT thread. (And unfortunately
call of invokeAndWait() can be dangerous.)

The problem is caused by calling NbPresenter.show() from findChild()
when findChild() helds lock which is AWT thread waiting for.

From thread dump the only solution I see is to avoid calling
NbPresenter.show() from Default Request Processor but use
invokeLater(). In AWT thread tree in ExplorerPanel is expanded and it
calls findChild() synchronously and it cannot be split. Any other idea?
Comment 7 _ pkuzel 2003-01-23 16:06:13 UTC
invokeLater may help. Would it work properly with modal dialogs>
Comment 8 mslama 2003-01-24 08:48:18 UTC
It should be ok when you do not need user response synchronously in
current non AWT thread (because code after invokeLater() is performed
further). But if you need return value to decide eg code flow if(ret)
{} else {} in current thread I am afraid it is not generally
solvable/safe.
Comment 9 _ pkuzel 2003-01-24 09:16:17 UTC
Created attachment 8666 [details]
Modality vs. blocking semantics test
Comment 10 _ pkuzel 2003-01-24 09:18:37 UTC
Attached test proves that setvisible(true) call is for:
  - modal dialogs blocking 
  - non-modal non-bloacking

So I think you can safelly add invoke later for non-modal dialogs.
Comment 11 mslama 2003-01-24 09:23:32 UTC
Yes when dialog is non modal show() returns immediatelly. It means
that in case of non modal dialog NbPresenter.show() could use
invokeLater() and not invokeAndWait(). Is such solution OK?
Comment 12 _ pkuzel 2003-01-24 09:41:09 UTC
I'm fine with it.
Comment 13 mslama 2003-02-03 13:44:37 UTC
Fixed in main trunk. show() is called asynchronously for non modal
dialogs to avoid deadlock.

Modified:
core/src/org/netbeans/core/NbPresenter.java r.1.76
Comment 14 dnoyeB 2003-02-08 15:05:01 UTC
Just an off the wall comment here.

invokeAndWait is not so much dangerous as it is revealing.  When it
does not work it often indicates some other issue.  I recently
deadlocked because I was calling invokeAndWait from a synchronized
method of a JFrame.  My method did not need to be synchronized so it
was an easy solution.  I can see NB is much more complicated though.

It would be interesting to see who is holding the lock on the current
object before you call invoke and wait on it, just as a test.
Comment 15 Marian Mirilovic 2004-03-05 22:35:20 UTC
verified