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 37045 - Infinite waiting after openning XML file (missed notification?)
Summary: Infinite waiting after openning XML file (missed notification?)
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Text (show other bugs)
Version: 3.x
Hardware: Sun SunOS
: P2 blocker (vote)
Assignee: Jaroslav Tulach
URL:
Keywords: RANDOM, THREAD
Depends on:
Blocks:
 
Reported: 2003-11-05 10:21 UTC by Marian Mirilovic
Modified: 2008-12-22 17:55 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
full thread-dump (8.57 KB, text/plain)
2003-11-05 10:21 UTC, Marian Mirilovic
Details
The automatic test that fails currently (7.22 KB, patch)
2004-02-25 06:34 UTC, Jaroslav Tulach
Details | Diff
Thread dump of the starving thread waiting in the openDocumentImpl (5.29 KB, text/plain)
2004-02-25 06:35 UTC, Jaroslav Tulach
Details
The fix I am about to apply (16.29 KB, patch)
2004-02-25 07:10 UTC, Jaroslav Tulach
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marian Mirilovic 2003-11-05 10:21:01 UTC
[nb new winsys](031104), [jdk1.4.2_02]

I cannot reproduce it again, but I have opened 5
xml files and than doubleclick on another xml node
in Filesystems window and deadlock happends (see
attached full thread-dump)
Comment 1 Marian Mirilovic 2003-11-05 10:21:27 UTC
Created attachment 12067 [details]
full thread-dump
Comment 2 _ pkuzel 2003-11-05 11:42:31 UTC
        at java.lang.Object.wait(Native Method)
        - waiting on <0xf0977590> (a
org.openide.windows.CloneableOpenSupport$Listener)

Does it wait for some dead thread?
Comment 3 Peter Zavadsky 2003-11-13 10:17:35 UTC
It is a lock in CloneableEditorSupport.
Comment 4 Petr Nejedly 2003-11-18 13:20:08 UTC
Seems like the notification branch haven't got executed.
I was thinking about missed notification, but this shouldn't be the
case, as both wait and notifyAll are in enough-covering synchronized
sections.
Comment 5 Miloslav Metelka 2003-11-18 14:49:58 UTC
Yes, it seems the AWT thread was not properly notified and it's still
waiting. Were there any other interesting conditions e.g. any
exceptions thrown etc. Could you please attach the ide.log?
Comment 6 Petr Nejedly 2003-11-27 11:58:34 UTC
How can it happen the notify() is not called (thinking outloud)?
Possibilities:
A) Load task not started because:
 A1) status==DOC_NO, but prepTask != null
 A2) exception in prepareDocument (e.g. in createEditorKit)
 A3) bug in RP
B) Load task started but didn't notified because:
 B1) status changed to DOC_NO (fast close) between open and run
 B2) document reference changed (more loads at once???)
 B3) Runtime exception during previous run()

B3, because of the finally clause of the runnable will cause
A1 on the next attempt, I think.

B1 can be caused by the fix of issue #37432, but the fix was
integrated after this bug.

Weren't there really no exceptions?
Comment 7 Petr Nejedly 2004-01-09 15:41:59 UTC
We should nail the editor document handling issues for 3.6
Comment 8 Petr Nejedly 2004-02-09 16:34:18 UTC
OK, I've managed to get the IDE to very similar state (infinite
waiting, but one level deeper in stack) just by OOME (or any other
non-java.lang.RuntimeException) during loading. I believe that by
fixing the state machine to handle correctly my test case, it will
solve this problem as well.
I'll keep working on it.
Comment 9 Jaroslav Tulach 2004-02-24 15:19:13 UTC
No you will not, I'll try it.
Comment 10 Jaroslav Tulach 2004-02-25 06:33:35 UTC
I think that after an hour I am able to reproduce the deadlock or
something very similar in a junit test.
Comment 11 Jaroslav Tulach 2004-02-25 06:34:38 UTC
Created attachment 13628 [details]
The automatic test that fails currently
Comment 12 Jaroslav Tulach 2004-02-25 06:35:31 UTC
Created attachment 13629 [details]
Thread dump of the starving thread waiting in the openDocumentImpl
Comment 13 Jaroslav Tulach 2004-02-25 07:10:10 UTC
Created attachment 13630 [details]
The fix I am about to apply
Comment 14 Jaroslav Tulach 2004-02-25 09:27:55 UTC
Checking in src/org/openide/text/CloneableEditorSupport.java;
/cvs/openide/src/org/openide/text/CloneableEditorSupport.java,v  <-- 
CloneableEditorSupport.java
new revision: 1.113; previous revision: 1.112
done
Processing log script arguments...
More commits to come...
RCS file:
/cvs/openide/test/unit/src/org/openide/text/Starvation37045Test.java,v
done
Checking in test/unit/src/org/openide/text/Starvation37045Test.java;
/cvs/openide/test/unit/src/org/openide/text/Starvation37045Test.java,v
 <--  Starvation37045Test.java
initial revision: 1.1
Comment 15 Petr Nejedly 2004-02-25 10:15:03 UTC
Can't agree.
Your thread dump is different from the reported one and the difference
is significant.
I believe that the original starvation was about the state, where
documentStatus is DOCUMENT_NO, but prepareTask != NULL.
This could happen if one calls prepareDocument and there is an
uncaught exception in the load task.
Subsequent call to openDocument will deadlock with the same thread
dump as the one reported.
I've just added such an exception to your test. It deadlocks, but
still have different thread dump.
To get the same thread dump, the test have to be modified to call
prepareDocument() first then wait till the prepareTask sucessfully
fails ;-) and then try openDocument.
Comment 16 Jaroslav Tulach 2004-02-25 11:05:17 UTC
Nice improvement of the testcase. The main difference seems to be in
throwing out an Error and not RuntimeException. If you thrown
exception, then the code would work. So I extended the
CloneableEditorSupport to also watch for Errors and correctly recover.
I am leaving this open and will try to investigate the improvements to
the test you mention, but I believe this is no longer high priority issue.


Checking in src/org/openide/text/CloneableEditorSupport.java;
/cvs/openide/src/org/openide/text/CloneableEditorSupport.java,v  <-- 
CloneableEditorSupport.java
new revision: 1.114; previous revision: 1.113
done
Processing log script arguments...
More commits to come...
Checking in test/unit/src/org/openide/text/Starvation37045Test.java;
/cvs/openide/test/unit/src/org/openide/text/Starvation37045Test.java,v
 <--  Starvation37045Test.java
new revision: 1.3; previous revision: 1.2
Comment 17 Jaroslav Tulach 2004-02-25 15:48:23 UTC
Petr made me to write a test that seems to mimic the original deadlock
problem. The fix was very easy. 

As a result of work on this bug we have discovered three ways how a
CloneableEditorSupport can be fooled by unexpected exceptions, we have
written tests, so everyone can reliably verify that the wrong
behaviour does not repeat and also we have provided fixes, that can be
verified by executing the new tests with old code vs. new code.


/cvs/openide/src/org/openide/text/CloneableEditorSupport.java,v  <-- 
CloneableEditorSupport.java
new revision: 1.115; previous revision: 1.114
done
Processing log script arguments...
More commits to come...
RCS file:
/cvs/openide/test/unit/src/org/openide/text/Starvation37045SecondTest.java,v
done
Checking in test/unit/src/org/openide/text/Starvation37045SecondTest.java;
/cvs/openide/test/unit/src/org/openide/text/Starvation37045SecondTest.java,v
 <--  Starvation37045SecondTest.java
initial revision: 1.1
Comment 18 Marian Mirilovic 2004-02-26 17:05:20 UTC
Ok, thanks , I can't reproduce it now - verified