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.
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...
Created attachment 37914 [details] The deadlock threaddump
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.
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.
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.
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