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 50328 - Deadlock when changing properties of freeform project
Summary: Deadlock when changing properties of freeform project
Status: CLOSED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Ant (show other bugs)
Version: 4.x
Hardware: PC Linux
: P1 blocker (vote)
Assignee: David Konecny
URL:
Keywords: THREAD
Depends on:
Blocks: 42682
  Show dependency tree
 
Reported: 2004-10-13 12:29 UTC by Milan Kubec
Modified: 2007-02-09 22:11 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
thread dumps (74.24 KB, text/plain)
2004-10-13 12:33 UTC, Milan Kubec
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Milan Kubec 2004-10-13 12:29:51 UTC
[200410121800, JDK 1.5.0_01]

Reproducible deadlock. Create freeform project but
don't set any source folder in the wizard. After
the project is created open its properties and add
source folder and close project properties. See
attached file - first three dumps are from first
occurence of the problem and other three deadlocks
are from reproduction.
Comment 1 Milan Kubec 2004-10-13 12:33:14 UTC
Created attachment 18253 [details]
thread dumps
Comment 2 Jesse Glick 2004-10-13 18:00:29 UTC
I think freeform.ui.View$RootChildren.updateKeys cannot call C.K.sK
synchronously; it has to use RequestProcessor or something.
Comment 3 David Konecny 2004-10-14 12:33:13 UTC
*** Issue 50355 has been marked as a duplicate of this issue. ***
Comment 4 David Konecny 2004-10-14 13:12:44 UTC
The problem is in FreeformSources.initSources() and its
ProjectManager.mutex().postWriteRequest() call. There are two threads:
EQ and RP. The FreeformSources.initSources() is called in RP, but EQ
already is in ProjectManager.mutex().readAccess(). That means that
ProjectManager.mutex().postWriteRequest() call in
FreeformSources.initSources() is blocking.

Before change in ProjectsRootNode$ProjectChildren.stateChanged (issue
50529) there was only one thread and therefore
ProjectManager.mutex().postWriteRequest() was non-blocking.

The simplest fix could be to not call
ProjectManager.mutex().postWriteRequest() from
FreeformSources.initSources() but post that to some other RP to make
it always non-blocking.
Comment 5 Jesse Glick 2004-10-14 18:13:46 UTC
I still disagree and think that making FreeformSources behave
asynchronously, and thus unpredictably, would be bad; and that the bug
here (at least what I can see from the last thread dump) is in
View$RootChildren.updateKeys: while being called from foreign code
which may be holding a lock, you may not acquire a new lock, and
currently C.K.sK acquires a lock and thus may not be called synch from
a callback.

The first thread dump seems to be something quite different - a lock
conflict between FreeformSources used as a monitor, and PM.mutex. That
appears to a totally different bug. fireChange is right to lock
*something* to make sure it has a consistent list of listeners, but
not FS.this, used for other purposes. It (and a/rCL) should probably
lock on 'listeners', not 'this'.

There are a lot of thread dumps in here, I did not analyze every one,
but you can see what I am getting at. In general, I do *not* want to
introduce new calls to RequestProcessor (asynchrony) in critical logic
methods without a very good reason. It hurts testability, produces
random bugs, and will often lead to other (harder) deadlocks anyway.
Comment 6 David Konecny 2004-10-15 10:29:28 UTC
"View$RootChildren.updateKeys: while being called from foreign code
which may be holding a lock, you may not acquire a new lock, and
currently C.K.sK acquires a lock and thus may not be called synch from
a callback." - after thinking about this thrice I now believe that you
are right and that this is real cause.

Also I reproduced isssue 50355 and got different tread dump so I will
reopen that issue and fix it differently.
Comment 7 David Konecny 2004-10-15 11:06:59 UTC
When children change is triggered by XML change then I made it
asynchronous. In other cases (addNotify()) I left it as it was.

Fixed in:
src/org/netbeans/modules/ant/freeform/ui/View.java;
new revision: 1.10; previous revision: 1.9
test/unit/src/org/netbeans/modules/ant/freeform/ui/ViewTest.java;
new revision: 1.2; previous revision: 1.1
Comment 8 rbalada 2004-10-18 13:36:09 UTC
David,

would you, please, merge the fix into branch QBE200410121800 as well?

Thanks
Comment 9 David Konecny 2004-10-18 14:02:39 UTC
Integrated to Q-build branch:
src/org/netbeans/modules/ant/freeform/ui/View.java;
new revision: 1.9.6.1; previous revision: 1.9
test/unit/src/org/netbeans/modules/ant/freeform/ui/ViewTest.java;
new revision: 1.1.12.1; previous revision: 1.1
Comment 10 Jesse Glick 2004-10-21 16:39:30 UTC
*** Issue 50704 has been marked as a duplicate of this issue. ***
Comment 11 Milan Kubec 2004-10-26 10:41:52 UTC
Verified in dev-200410241800.
Comment 12 Jesse Glick 2007-02-09 22:11:10 UTC
Issue #58491 is similar.