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 16966 - Is it ok to call Lookup from MultiDataObject.Entry methods?
Summary: Is it ok to call Lookup from MultiDataObject.Entry methods?
Status: CLOSED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Data Systems (show other bugs)
Version: 3.x
Hardware: Sun SunOS
: P3 blocker (vote)
Assignee: David Strupl
URL:
Keywords: THREAD
Depends on:
Blocks:
 
Reported: 2001-10-25 17:08 UTC by David Kaspar
Modified: 2008-12-22 21:21 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Full thread dump (11.98 KB, text/plain)
2001-10-25 17:10 UTC, David Kaspar
Details
new Full Thread Dump (2.23 KB, text/plain)
2001-10-26 16:36 UTC, David Kaspar
Details
Correct Full Thread Dump - ignore previous attachment (11.94 KB, text/plain)
2001-10-26 16:43 UTC, David Kaspar
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Kaspar 2001-10-25 17:08:18 UTC
See attachment for Full thread dump.
Comment 1 David Kaspar 2001-10-25 17:10:17 UTC
Created attachment 3149 [details]
Full thread dump
Comment 2 _ ttran 2001-10-25 22:09:50 UTC
I see also editor code in stack but lookup looks more suspicious =>
jtulach

dkaspar, can you reproduce the problem?  If the deadlock happens often
then please raise prio to P2, if it happens very often (sure steps to
reproduce it) then P1
Comment 3 Svata Dedic 2001-10-26 07:30:10 UTC
IMO Lookup is (quite) innocent. I suspect that JavaDataObject
attempted to locate the indentation engine, while holding lock on
itself (createFromTemplate synchronizes *then* calls
handleCreateTemplate) - and the FolderRecognizer attempted to lock the
same (data) object.
Comment 4 Martin Roskanin 2001-10-26 09:29:19 UTC
Yes, I looked at it yesterday, to find out if it is editor issue.
The problem seems to be in these two threads

1.)
Thread-28:
at 
org.openide.loaders.MultiDataObject.handleCreateFromTemplate(MultiData
Object.java:523)
...
 synchronized (getSecondary ()) {
-getting lock
...


2.)
Folder recognizer:
at 
org.openide.loaders.MultiDataObject.markSecondaryEntriesRecognized(Mul
tiDataObject.java:209)
...
synchronized (secondary) {
-Deadlock
...
Comment 5 Jaroslav Tulach 2001-10-26 09:53:07 UTC
Good investigation Mato.

This is nearly unfixable. The problem is that MultiDataObject does
calls subclasses code while holding internal lock, it blocks on folder
processor and folder processor blocks on the MultiDataObject internal
lock. But I can imagine thousands different scenarios when the code
blocks.

Solutions:
1. either do not hold internal lock when calling subclasses methods =>
in this case we would not copy one entry (I guess)
2. improve the markAsRecognized => not sure whether it would help, but
might.
3. create easy fix in java data object

I vote for 3, fix the problem by overriding handleCreateFromTemplate
and initializing the indentation engine and after that calling to
super.handleCreateFromTemplate. If possible.

Then return the bug to loaders. We will write tests to identify the
possible deadlocks and try to enhance the behaviour somehow....
Comment 6 David Kaspar 2001-10-26 16:33:32 UTC
This bug is fully reproducible - raising priority.
How to reproduce
Installed ORBacus 4.x is needed.
Build CORBA.nbm
Start NB build #011026
Autoupdate CORBA.nbm
Create IDL from "CORBA | Simple" template in root of sampledir filesystem
Change IDL to this:
interface Simple {
  string op (in string aa);
};
Select Simple.idl in the Explorer
Do "Tools | CORBA Wizard..." main menu action.
Press Next.
Check Create Server, Create Client, Create Implementation checkboxes.
Press Next.
Select ORBacus 4.x ORB
Select IOR to standard output
Press Next three times
Press Finish
IDL is compiled, implementation is generated.
ERROR - Deadlock
See attachment for new Full Thread Dump
Comment 7 David Kaspar 2001-10-26 16:36:40 UTC
Created attachment 3166 [details]
new Full Thread Dump
Comment 8 David Kaspar 2001-10-26 16:43:24 UTC
Created attachment 3167 [details]
Correct Full Thread Dump - ignore previous attachment
Comment 9 Svata Dedic 2001-10-26 16:48:56 UTC
Fixed in trunk.

/cvs/java/src/org/netbeans/modules/java/CodeGenerator.java,v  <-- 
CodeGenerator.java
new revision: delete; previous revision: 1.21
Checking in IndentFileEntry.java;
/cvs/java/src/org/netbeans/modules/java/IndentFileEntry.java,v  <-- 
IndentFileEntry.java
new revision: 1.6; previous revision: 1.5
Checking in JavaDataObject.java;
/cvs/java/src/org/netbeans/modules/java/JavaDataObject.java,v  <-- 
JavaDataObject.java

Reassigning back to openide and lowering the priority. The necessary
condition for the deadlock was broken in java module.
Comment 10 _ ttran 2001-10-28 14:18:04 UTC
Yarda, up to you to decide what's next.  This is a general threading
issue.
Comment 11 Jaroslav Tulach 2001-10-29 08:49:00 UTC
Very likely we will not do anything with it for 3.3. A bit dangerous
to mangle with this code.


One possible fix would be to stop using locks and move the processing
into Folder Recognizer thread. That might be fine, because most of the
invocations are done by that thread anyway. The code would look like:

if (FolderList.isRecognizerThread ()) {
	runNow ();
} else {
	FolderList.postTask (runLater ());
}

But first of all someone should write a test that will reproduce the
deadlock and we will know what we want to fix.



Comment 12 Jaroslav Tulach 2002-06-28 09:30:29 UTC
The actual problem is fixed and I suggest not to fix the general issue
in current data system implementation, but concentrate on preventing
this in the new one.

Because the mark secondaryEntriesRecognized method is not in the new
design and all its tasks are handled by the infrastructure itself, I
believe that this kind of general problem cannot occur anymore.

I would like David to review the code in the new data systems and if
he agrees with this, then close this issue.
Comment 13 David Strupl 2002-06-28 13:28:12 UTC
Taking into account Svata's fix and Jarda's claims I am closing this
as fixed for now.
Comment 14 David Kaspar 2002-11-11 13:24:44 UTC
Verified
Comment 15 Quality Engineering 2003-07-01 16:15:42 UTC
Resolved for 3.4.x or earlier, no new info since then -> closing.