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 38661 - Deadlock in editor during file reload
Summary: Deadlock in editor during file reload
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Text (show other bugs)
Version: 3.x
Hardware: PC Linux
: P2 blocker (vote)
Assignee: Petr Nejedly
URL:
Keywords: RANDOM, THREAD
Depends on:
Blocks:
 
Reported: 2004-01-12 17:02 UTC by ehucka
Modified: 2008-12-23 00:13 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Deadlock's threaddump. (10.45 KB, text/plain)
2004-01-12 17:03 UTC, ehucka
Details
An exception thrown before deadlock. (1.42 KB, text/plain)
2004-01-12 17:04 UTC, ehucka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ehucka 2004-01-12 17:02:29 UTC
Build 200401111900

Deadlock occured after the opening of file.
Comment 1 ehucka 2004-01-12 17:03:13 UTC
Created attachment 12840 [details]
Deadlock's threaddump.
Comment 2 ehucka 2004-01-12 17:04:17 UTC
Created attachment 12841 [details]
An exception thrown before deadlock.
Comment 3 Miloslav Metelka 2004-01-23 11:54:45 UTC
The exception is probably unrelated - it's deadlock related to the
document loading in openide.text.
I do not clearly understand why the document loading thread cannot
proceed. Both threads - AWT and the first RP should not have access to
the document prior to its complete loading. The only exception would
be reloading of the file.

Emane, it's likely hard to remember ;-) but was not there an external
modification to the file done prior to opening of it?
Comment 4 ehucka 2004-01-23 12:37:32 UTC
Probably, it was.
Comment 5 Miloslav Metelka 2004-02-02 15:56:02 UTC
I've eplored the stacktrace again and it appears that there is  a
document loading and the situation is like this:

1) JavaParser RP
  - holds read lock over the document -
org.netbeans.editor.BaseDocument.render(BaseDocument.java:883)
  - waits for prepareDocument() task to finish

2) Document Loading RP
  - wants to acquire the write lock on the document in order to load
the new document content

3) AWT
  - similar to 1) i.e. it has acquired the readLock() and waits for
prepareDocument() task to finish

As the 2) cannot proceed due to existing read locks from 1) and 3) the
document loading will not finish but that blocks 1) and 3).

Unfortunately I see no easy solution how to avoid this kind of
deadlock. The document seems to already be known to the threads 1) and
3) and they acquire read lock on it prior to the loading RP acquires
the write lock on it and starts actual loading.
 Reassigning to openide/editor to Petr N. for further evaluation. I
hope that I have overlooked something that could help to fix this problem.
Comment 6 Petr Nejedly 2004-02-05 09:58:50 UTC
I've evaluated the problem, and the only solution I've found is to
perform the whole reload operation under a write lock - that is, not
only the load but also all the work with state machines and so on.
I'll try to verify this desigh.
Comment 7 Petr Nejedly 2004-02-17 12:27:50 UTC
Should fix this for 3.6
Comment 8 Petr Nejedly 2004-02-20 16:52:04 UTC
Seems like doing the reload synchronously and in writelock is the best
way to solve this. I have a working patch now, I'll try to also clean
up the code a bit.
Comment 9 Petr Nejedly 2004-02-26 15:45:48 UTC
Fixed as outlined above.
openide/src/org/openide/text/CloneableEditorSupport.java,v1.116
Comment 10 Lukas Hasik 2004-02-26 17:01:44 UTC
Eman, could you verify ? Thanks.
Comment 11 ehucka 2004-02-27 10:21:43 UTC
I haven't seen the deadlock for a long time. I belive the fix will help.