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 49466 - Deadlock with opened project properties
Summary: Deadlock with opened project properties
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 4.x
Hardware: PC Windows XP
: P2 blocker (vote)
Assignee: Petr Nejedly
URL:
Keywords: THREAD
Depends on:
Blocks:
 
Reported: 2004-09-23 11:11 UTC by Lukas Hasik
Modified: 2008-12-22 22:36 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
3 thread dumps (47.00 KB, text/plain)
2004-09-23 11:12 UTC, Lukas Hasik
Details
Simplified and commented thread dump. (10.70 KB, text/plain)
2004-09-23 15:15 UTC, Petr Nejedly
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lukas Hasik 2004-09-23 11:11:35 UTC
20040922 + me + jdk1.5.0-b63 

ide didn't wake up when I returned to it after while.

see attached threaddump

what i did before deadlock:
Opened project properties, added new emulator,
closed platform manager, left the ide with opened
project properties, worked with mozilla and tried
rerurn to ide - deadlock, had to kill ide.
Comment 1 Lukas Hasik 2004-09-23 11:12:09 UTC
Created attachment 17827 [details]
3 thread dumps
Comment 2 Adam Sotona 2004-09-23 11:42:55 UTC
It looks like there is several threads waiting on some Mutex but
nobody is inside any Mutex (and working or locked for some other reason).
So this seems to be a bug in Mutex implementation for me.
Comment 3 Petr Nejedly 2004-09-23 15:13:40 UTC
Not simple at all.
There are some threads inside some Mutexes and trying to obtain
others, but still it isn't clear what's wrong.
I'll attach commented snippet of the thread dump with all important
threads.
Generally, there are two Mutex instances involved, Children.MUTEX and
ProjectManager.mutex() (actually three, also Mutex.EVENT, but it has
no important role there).

In the attached partial dump, the first thread is writer in Ch.MUTEX
and tries also to obtain a read access on PM.mutex.

The second thread is just leaving write access of PM.mutex and running
postReadRequest() attached runnables. So the thread owns read access
on PM.mutex and also wants to get a write access on Ch.MUTEX (which is
blocked by 1st thread).

The third thread (AWT) just wants to enter as a writer to PM.mutex


My understanding of the problem is that our Mutex has no starvation
prevention policy and does no reordering.
The PM.mutex is only readlocked, so the first thread should be able to
proceed, but the third thread is queued before it with its write
request (please note that I haven't verified this behaviour of Mutex yet).

In that case, it may be possible to fix it in Mutex, but i'm still a
bit nervous about the first two threads and their locks.



Comment 4 Petr Nejedly 2004-09-23 15:15:38 UTC
Created attachment 17838 [details]
Simplified and commented thread dump.
Comment 5 Petr Nejedly 2004-09-23 16:18:19 UTC
I've managed to simulate the problem in a test (uff need some time to
single-threadize my brain again...).
Will continue later.
Comment 6 Jesse Glick 2004-09-23 18:14:40 UTC
The fundamental problem is that Children.Keys should never have been
written to use a r/w lock at all. It doesn't make any sense - you
never "write" data to a C.K subclass, it simply listens for changes in
other data models and refreshes its display accordingly. It should be
running as a normal GUI component would, in the EQ with no funny locks.

ProjectsRootNode.ProjectChildren.stateChanges could of course refresh
its keys later. Might be best to simply call refreshKey in EQ (as
issue #35833's patch does for you automatically, in fact).
Comment 7 Petr Nejedly 2004-09-27 16:50:42 UTC
I've added test to Mutex that simulates the problem.
I'm blaming mutex for the problem although it would be simpler to fix
the problem elsewhere.

It seems like Mutex does not wake up other readers during
leaveX/attached readers processing. The third thread is not needed for
the deadlock.
Comment 8 Petr Nejedly 2004-09-27 22:37:35 UTC
Have a fix, Testing it now.
Comment 9 Petr Nejedly 2004-09-29 07:05:42 UTC
Fixed in Mutex:

openide/src/org/openide/util/Mutex.java,v1.62
openide/test/unit/src/org/openide/util/MutexTest.java,v1.11

Comment 10 Lukas Hasik 2006-08-04 10:26:07 UTC
v