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 115364 - Applying Design Pattern while Design View is open kills IDE
Summary: Applying Design Pattern while Design View is open kills IDE
Status: VERIFIED FIXED
Alias: None
Product: xml
Classification: Unclassified
Component: Schema Tools (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Samaresh Panda
URL:
Keywords: RANDOM
Depends on:
Blocks:
 
Reported: 2007-09-12 15:48 UTC by Mikhail Matveev
Modified: 2008-03-19 18:21 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Log file from Ubuntu Linux (265.14 KB, application/octet-stream)
2007-09-12 17:15 UTC, tonybeckham
Details
Thread dump from Mac when deadlock hit. (27.07 KB, application/octet-stream)
2007-09-13 19:13 UTC, tonybeckham
Details
axiom jar (521.57 KB, application/octet-stream)
2007-11-12 18:45 UTC, Samaresh Panda
Details
patch (1.26 KB, text/plain)
2007-11-13 01:06 UTC, Samaresh Panda
Details
Thread dump from Mac after second transformation (27.76 KB, text/plain)
2008-01-17 18:51 UTC, tonybeckham
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail Matveev 2007-09-12 15:48:09 UTC
1. Create newLoanApplication schema.
2. Switch to Design View.
3. Apply Design Pattern "Garden of Edem" or "Alami Slice" (one which creates new complex types).
Result: after creating several complex types, IDE hangs up.

Checked on WinXP, MACOSX and MacIntel. On Macs, it happens consistently, on WinXP - from time to time.
Comment 1 Samaresh Panda 2007-09-12 16:57:57 UTC
Visible problem.
Comment 2 tonybeckham 2007-09-12 17:13:56 UTC
Product Version: NetBeans IDE 6.0 Beta 1 (Build 200709111000) 
Java: 1.6.0; Java HotSpot(TM) Client VM 1.6.0-b105 
System: Linux version 2.6.20-16-generic running on i386; UTF-8; en_US (nb)

I tried this on linux and the IDE never hangs but there are a lot of errors in the log file.  I'm going to attach it. 
And yes, 100% of the time on Mac.
Comment 3 tonybeckham 2007-09-12 17:15:17 UTC
Created attachment 48674 [details]
Log file from Ubuntu Linux
Comment 4 tonybeckham 2007-09-12 20:58:16 UTC
Sam has provided us with a patch that fixes the problem.  Once that fix is checked into trunk we can verify and close
this issue.  Great work Sam!
Comment 5 Samaresh Panda 2007-09-12 21:33:55 UTC
Fix integrated:
/cvs/xml/schema/abe/src/org/netbeans/modules/xml/schema/abe/AutoSizingPanel.java
new revision: 1.5; previous revision: 1.4
/cvs/xml/schema/abe/src/org/netbeans/modules/xml/schema/abe/ModelEventMediator.java
new revision: 1.7; previous revision: 1.6
/cvs/xml/schema/abe/src/org/netbeans/modules/xml/schema/abe/ElementPanel.java
new revision: 1.7; previous revision: 1.6
/cvs/xml/schema/abe/src/org/netbeans/modules/xml/schema/abe/ContainerPanel.java
new revision: 1.7; previous revision: 1.6
Comment 6 tonybeckham 2007-09-13 19:12:32 UTC
Did the changes make it into this build: NetBeans IDE Dev (Build 200709130000)?
Because it is happening again.  I'll attach a thread dump for you.
Comment 7 tonybeckham 2007-09-13 19:13:16 UTC
Created attachment 48766 [details]
Thread dump from Mac when deadlock hit.
Comment 8 Samaresh Panda 2007-09-13 19:34:28 UTC
I have a feeling that the fix is somehow not in the build. In fact, it is very easy to verify. Apply the patch I gave
you earlier on the build and see what happens.
Comment 9 tonybeckham 2007-09-13 19:59:30 UTC
I'm not sure what happened but the first time I installed NetBeans IDE Dev (Build 200709130000) I hit the deadlock first
try that is why I reopened.  
I uninstalled the IDE deleted my usr dir and .nbi file reinstalled and now I cannot reproduce it.  
I tried that because I could not reproduce on Win XP or Linux so I knew the fixes were there.
Comment 10 tonybeckham 2007-09-18 23:28:30 UTC
Fix VERIFIED 

Product Version: NetBeans IDE Dev (Build 200709180000) 
Java: 1.5.0_07; Java HotSpot(TM) Client VM 1.5.0_07-87
Comment 11 Mikhail Matveev 2007-11-12 16:36:30 UTC
I can reproduce it for RC1. WinXP, JDK1.6.

Can't give a consistent scenario, but it seems that doing a refactoring operation (rename) and expanding "Elements" and
"Cpmlex Types" nodes before applying design pattern increases chance of facing the problem.
Comment 12 Mikhail Matveev 2007-11-12 17:31:11 UTC
It can be reproduced often after steps in 121758. But it happens in other cases also.
Comment 13 Samaresh Panda 2007-11-12 17:44:42 UTC
Looking into it.
Comment 14 Samaresh Panda 2007-11-12 18:43:23 UTC
Please apply the jar(copy to ide8/modules) and verify the fix. If it works, I'll request for integration in release60
branch.
Comment 15 Samaresh Panda 2007-11-12 18:45:07 UTC
Created attachment 52896 [details]
axiom jar
Comment 16 Samaresh Panda 2007-11-13 00:43:56 UTC
Fixed in trunk.
/cvs/xml/axi/src/org/netbeans/modules/xml/axi/impl/AXIModelImpl.java,v  <--  AXIModelImpl.java
new revision: 1.7; previous revision: 1.6
Comment 17 Samaresh Panda 2007-11-13 01:05:29 UTC
Please see the attached patch. The fix ensures that the needsSync() method is carried out by one thread at a time and
this does not affect any other areas of the IDE.
Comment 18 Samaresh Panda 2007-11-13 01:06:16 UTC
Created attachment 52906 [details]
patch
Comment 19 tonybeckham 2007-11-13 01:15:35 UTC
OK, I have tested some other areas and do not see any issues with the patch.  I give a go ahead for integration into HR
branch from my side.
Comment 20 _ tboudreau 2007-11-13 11:11:10 UTC
[originally posted to patch review list]

Perhaps I am ignorant, but this is the first time I have ever seen *more* synchronization solve a deadlock - it suggests that the original code was over-
synchronized to begin with, and the solution is to create a bottleneck before whatever bottleneck caused the problem - so a real fix is to rethink the threading 
model for all the code having the problem.

The fact that the method whose signature gets "synchronized" added to it is one called "needsSync" suggests that someone was trying to create a fast non-
blocking test for whether or not something needs to be updated, and probably the fix will make it blocking and that will have side-effects elsewhere.

So, do this if it is what is needed to to ship 6.0, but it smells bad and should be revisited after.  I tried to review the patch but it is too minimal to know what 
will change.
Comment 21 Nam Nguyen 2007-11-13 15:12:11 UTC
I came to the same conclusion as Tim about the patch.  I was not able to reproduce deadlock with my trunk build (without
the fix).   I suggest the best action is to reopen the bug and adjust the priority to P2 due to lack of reliable way to
reproduce and the described test case seems (apply pattern -> rename -> undo...) - IMO, not a frequent usage of schema
editing.

The effort to fix should be directly derived from the deadlock analysis.
Comment 22 Mikhail Matveev 2007-11-13 15:18:40 UTC
I'm able to reproduce the issue WITH the patch applied.
Can't provide thread dump: by some reason, thread dump shortcut doesn't work.
Comment 23 Mikhail Matveev 2007-11-13 16:53:59 UTC
We have discussed the issue. It seems that it happens rarely enough, and the fix may be risky and not exactly solves the
problem. So, the best decision is to decrease bug priority to P2 and wait for more appropriate fix and more appropriate
time to do it, and I'm doing so.
Comment 24 Samaresh Panda 2007-11-13 17:13:44 UTC
Tim,
I agree with you. Yes, there is over-synchronization but is too risky to revisit the threading model in xam at this
point. I'll revert my changes, since it doesn't really fix the problem, though I was given a go before. And I feel sorry
for the mess.
Comment 25 Mikhail Matveev 2008-01-17 10:28:52 UTC
Unable to reproduce in the current Netbeans 6.1 build on WinXP. Will try more.
Comment 26 tonybeckham 2008-01-17 18:50:05 UTC
Applying Garden of Eden pattern is OK, but if I try and apply another pattern after the transformation the IDE hangs. 
I'll attach the thread dump.  It says there is a deadlock.

Product Version: NetBeans IDE Dev (Build 200801170000)
Java: 1.5.0_13; Java HotSpot(TM) Client VM 1.5.0_13-119
System: Mac OS X version 10.5.1 running on i386; MacRoman; en_US (nb)
Comment 27 tonybeckham 2008-01-17 18:51:18 UTC
Created attachment 55216 [details]
Thread dump from Mac after second transformation
Comment 28 tonybeckham 2008-01-17 19:31:12 UTC
Actually, sometimes the deadlock is hit when doing first transformation (to garden of Eden) on Mac.
Comment 29 tonybeckham 2008-01-17 22:48:15 UTC
I found that I hit the deadlock when I start the IDE from the command line.  Specifically, if I first cd to
<InstallDir>\bin then run netbeans the deadlock happens when applying design pattern in design view.  However, if I run
the IDE from the command line by .<Installdir>\bin\netbeans it doesn't happen.
Comment 30 tonybeckham 2008-01-17 23:16:38 UTC
Unfortunately, it turns out that the problem can be hit no matter what way you start the IDE, from command line or from
launcher icon.  Just some ways lead to hitting it easier than others.
Comment 31 tonybeckham 2008-01-22 20:19:41 UTC
System Info:
Product Version: NetBeans IDE Dev (Build 200801220251)
Java: 1.6.0_04; Java HotSpot(TM) Client VM 10.0-b19
System: Linux version 2.6.22-14-generic running on i386; UTF-8; en_US (nb)

Not able to reproduce on Linux. Looking more and more like a Mac only issue.
Comment 32 Samaresh Panda 2008-01-24 00:29:22 UTC
I'm unable to reproduce this on Windows, nor in Solaris. In any case, will try to make a patch for Mac.
Comment 33 Samaresh Panda 2008-03-17 20:29:59 UTC
Fix integrated: http://hg.netbeans.org/main?cmd=changeset;node=8d0ebd95c4d6.
Comment 34 tonybeckham 2008-03-19 18:21:54 UTC
Fix Verified

Product Version: NetBeans IDE Dev (Build 200803191206)
Java: 1.5.0_13; Java HotSpot(TM) Client VM 1.5.0_13-119
System: Mac OS X version 10.5.2 running on i386; MacRoman; en_US (nb)