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 32313 - NB freezes if a file being internationalized is read only
Summary: NB freezes if a file being internationalized is read only
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Text (show other bugs)
Version: 3.x
Hardware: PC Windows ME/2000
: P3 blocker (vote)
Assignee: David Konecny
URL:
Keywords: RANDOM, THREAD
Depends on:
Blocks:
 
Reported: 2003-03-25 19:34 UTC by jsinai
Modified: 2008-12-22 21:52 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Thread dump after NB freezes (39.09 KB, text/plain)
2003-03-26 20:14 UTC, jsinai
Details
excerpt from the original log showing the two problematic threads (4.30 KB, text/plain)
2003-03-31 12:57 UTC, David Konecny
Details
proposed patch (1.27 KB, patch)
2003-03-31 13:29 UTC, David Konecny
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jsinai 2003-03-25 19:34:31 UTC
I'm using Clearcase, where files are read only till 
checked out. I was internationalizing a folder full of 
files, but forgot to check out the bundle. The wizard 
froze after the second screen (when it starts processing 
the files), and it froze the whole program. Instead, it 
should warn the user, and quit the wizard.
Comment 1 _ pkuzel 2003-03-26 10:27:24 UTC
I cannot reproduce on local filesystem with readonly files.

So I guess you are refering to virtual files created by NetBeans
clearCase module. Do you?

Please attach freeze thread dump.
Comment 2 pfelenda 2003-03-26 14:52:17 UTC
I tried set some java and properties files to read-only, but I cann't
reproduce the freeze. 
(only 1-3 seconds IDE repainted windows)
I tested "Internationalize..." and "Internationalization Wizard"
feature from menu.

Could you please add some detailed description:
IDE version - there is info about IDE in About dialog ( from main menu
Help|About ),
Java version,
and detailed steps to reproduce this issue.

Thanks
Comment 3 jsinai 2003-03-26 16:48:35 UTC
If this is not easy to reproduce, then maybe it should be 
closed.

I was using a local filesystem also (the clearcase 
integration appears not to work for nb 3.5).

IDE version: IDE/1 spec=3.38 impl=200302190100
Java 1.4.1_01

If you still want the freeze thread dump, let me know 
where to find it.

Julian
Comment 4 _ pkuzel 2003-03-26 17:09:50 UTC
Thread dump = Ctrl + Break pressed in console window while IDE seems
to be frozen.
Comment 5 jsinai 2003-03-26 20:14:55 UTC
Created attachment 9551 [details]
Thread dump after NB freezes
Comment 6 _ pkuzel 2003-03-27 10:20:51 UTC
So it looks like deadlock at <049F6C78> lock.

One possible solution is to use private lock in
UndoRedo.Manager.addChangeListener as it can be subclassed and
subclass shares the same lock.
Comment 7 _ ttran 2003-03-31 10:29:11 UTC
Undo/Redo is core/editor subcat, I think
Comment 8 David Konecny 2003-03-31 12:57:34 UTC
Created attachment 9604 [details]
excerpt from the original log showing the two problematic threads
Comment 9 David Konecny 2003-03-31 13:29:09 UTC
Created attachment 9605 [details]
proposed patch
Comment 10 _ pkuzel 2003-03-31 13:47:39 UTC
David it cannot work. You must get rid of synchronized (this) and
replace it by synchronized(PRIVATE_LOCK) where private lock is a field
declared as:

  private transient Object PRIVATE_LOCK = new Object();
Comment 11 David Konecny 2003-03-31 13:53:42 UTC
(all this was written before Peter's previous comment - will reply to
it separately)
I attached simple patch which should hopefully prevent the problem. I
agree with PetrK that problem is in synchronization of
UndoRedo.Manager.addChangeListener() which seems to me not necessary.

However the cause is in CloneableEditorSupport.revertUpcomingUndo()
method. Peter Zavadsky could you please look at my last two
attachments? The first one shows the problem and second is patch.
What's your opinion on it? The CES.revertUpcomingUndo() was added by
you recently. The problem is that thread A calls setUndoTask with new
UndoTask and then it calls synchronized UndoRedo.addChangeListener().
However, the UndoTask which was set is immediatelly started (let say
thread B) and  it calls UndoRedo.undo() which is synchronized as well.
The result is that A hold write lock on document and waits on B and B
waits on write lock. Other possible way how to solve it would be to
reorder calls in revertUpcomingUndo(): first
UndoRedo.removeChangeListener(), then setUndoTask() and then
UndoRedo.addChangeListener. This should prevent the problem as well
because nobody could start UndoTask because there would be no listener.

At the moment it seems to me that both these changes should be applied
as they make sense to me, but would like to hear PeterZ's opinion.

Should it be fixed for NB35? I do not know. I would like to ask QA to
test some scenarios similar to Julian's one and then decide. From the
Julian report it looks that it is always reproducible. How frequent
this scenario is I do not know. From other comments in this issue it
looks that it is not general problem of readonly files.

The fixes I proposed are relatively isolated and should not have
sideeffects. However I must admit that I do not understand why this
problem happens (and source code is not clear to me either) and so the
fix can solve the problem just partially.
Comment 12 David Konecny 2003-03-31 13:56:43 UTC
PetrK: the problem happens only when list!=null so it should work I guess.
Comment 13 _ pkuzel 2003-03-31 14:01:09 UTC
Right, but this way you can create two list instances, resulting in
one listener getting discarded.
Comment 14 Marian Mirilovic 2003-03-31 14:23:22 UTC
> Should it be fixed for NB35? I do not know. I would like to ask QA to
> test some scenarios similar to Julian's one and then decide.

I've tried it without success,but I haven't clearcase, I've tried it
only with cvs and read-only files.

> From the Julian report it looks that it is always reproducible. How
frequent
> this scenario is I do not know. From other comments in this issue it
> looks that it is not general problem of readonly files.

I don't reccomend fix this one for release35:
-  We cannot reproduce it, it's reported only by one user, it's
reproducible only by the specific occurence, we will not be able
verify fix, ...
Comment 15 Peter Zavadsky 2003-03-31 14:34:50 UTC
Just a little note: The cause isn't in CES.revertUpComingUndo()
method, but in UndoRedo class - even you are pointing out to that  code.

In this case it is a problem UndoRedo uses itself as a lock (which is
exposed that way) for lazy init its listener list. And the same lock
is used in CES/subclasses for other purposes.

That's wrong.

To the fix. Generally if some class uses synch blocks for its field,
it should use some internal locks, not exposed ones.

However in this case I would prefer remove the synch  modifier at all
and set the list field as final and initialize it directly at
declaration. I guess the lazy init doesn't have a sense here.



Comment 16 David Konecny 2003-03-31 15:30:19 UTC
Thanx. Will fix it once the trunk is buildable. Marking as P3.
Comment 17 David Konecny 2003-04-01 07:46:18 UTC
Fixed in:
Checking in src/org/openide/awt/UndoRedo.java
new revision: 1.23; previous revision: 1.22
Comment 18 jsinai 2003-07-08 17:58:08 UTC
Fixed.