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 93789 - Editor deadlock when editing document and creating embedding
Summary: Editor deadlock when editing document and creating embedding
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Lexer (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Miloslav Metelka
URL:
Keywords:
Depends on:
Blocks: 94383
  Show dependency tree
 
Reported: 2007-02-01 12:29 UTC by Marek Fukala
Modified: 2007-02-16 18:51 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
The deadlock threaddump (17.27 KB, text/plain)
2007-02-01 12:30 UTC, Marek Fukala
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Fukala 2007-02-01 12:29:50 UTC
I found a deadlock in html editor when I edited an opened HTML document and the
html parser finished in the same moment. See the attached threaddump to evaluate.

Question: Am I allowed to call the tokenSequence.createEmbedding() outside from
EDT? Currently I do it from default RP. I can fix the problem by putting the
call to EDT, but I am not sure if it is the best way...
Comment 1 Marek Fukala 2007-02-01 12:30:51 UTC
Created attachment 37914 [details]
The deadlock threaddump
Comment 2 Vitezslav Stejskal 2007-02-02 00:42:42 UTC
I am not sure if I can see the deadlock. What threads are deadlocked?

Also, Mila is probably a better person for talking about overall synchronization
concept in editor and lexer, but I was under the impression that anything around
lexer should be happening under the document's read lock. That's at least the
concept I assumed for building the Highlighting SPI. Looking at your threaddump
I am not too sure anymore.
Comment 3 Miloslav Metelka 2007-02-02 07:45:54 UTC
I see a problem - the createEmbedding() locks the root token list but that
prevents other threads from fetching of the tokens from it which then leads to
the deadlock. That's not strictly necessary (the embedding does not affect the
root list; on the other hand I'm trying to use as few various objects as
monitors as possible to make the locking model clear). I'm still evaluating
what's the best model for this before making the final fix.
Comment 4 Miloslav Metelka 2007-02-16 17:58:48 UTC
I will implement a solution where the monitor of the root token list will only
be locked
1) For accessing of the embedding container. There may be a creation of the
wrapping EC necessary so this needs to by synced to prevent creation of two ECs.
2) When adding the created embedding into the EC.
The subsequent firing of a token hierarchy change will be done outside of the
root token list lock.
This should prevent holding a lock during the creation of the embedding which
should eliminate the deadlock.
Comment 5 Miloslav Metelka 2007-02-16 18:51:55 UTC
Should be fixed in the trunk.
Checking in src/org/netbeans/lib/lexer/EmbeddingContainer.java;
/cvs/lexer/src/org/netbeans/lib/lexer/EmbeddingContainer.java,v  <-- 
EmbeddingContainer.java
new revision: 1.4; previous revision: 1.3