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 253430 - NetBeans editor deadlocks while editing
Summary: NetBeans editor deadlocks while editing
Status: NEW
Alias: None
Product: editor
Classification: Unclassified
Component: Spellchecker (show other bugs)
Version: 8.0.2
Hardware: PC Linux
: P3 normal (vote)
Assignee: Milutin Kristofic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-12 21:37 UTC by arren
Modified: 2015-11-03 05:07 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
jstack for deadlock (17.03 KB, text/plain)
2015-07-12 21:37 UTC, arren
Details
messages.log (203.12 KB, application/octet-stream)
2015-07-15 21:42 UTC, arren
Details

Note You need to log in before you can comment on or make changes to this bug.
Description arren 2015-07-12 21:37:22 UTC
Created attachment 154582 [details]
jstack for deadlock

See attachment for jstack. Clearly deadlocked in the AWT thread. Something on another thread has held the lock that the AWT thread ought to be able to acquire fast.

Can NOT reproduce at will, but HAS reproduced 3 times now. Not sure if this is a spellchecker bug, but that appears in the non-AWT-thread stack.
Comment 1 err 2015-07-12 22:58:41 UTC
Deadlock, upping the priority.

The associated messages.log might be useful. Sometimes an exception can put
things into a bad state.

"ViewHierarchy-Region-Rebuilding", while holding the document readlock,
is stuck trying to get its "PriorityMutex"

The AWT-EQ thread is trying to get the document writelock
through the DefaultKeyTypedAction.

The spellchecker is waiting for the EventQ.

osgi is in there.
Comment 2 err 2015-07-13 00:50:45 UTC
BTW, this is while editing a "Velocity" file. The reporter has this to say

    Velocity has a syntax highlighting plugin, but it didn't appear as a
    file type in the spellchecker preferences, so I unticked plain text
    (and most other things) in the spellchecker preferences because I
    have to do work, and netbeans hung up three times today, and
    restarting it takes about 10 minutes.

The implication is that the failure definitely is related to spellchecker.
Comment 3 Milutin Kristofic 2015-07-13 11:14:48 UTC
Can you please attach message.log? I don't know what is your Netbeans version, what plugins you have installed. 

Messages.log is in user directory, you can find path to user directory in Help/About in Netbeans Menu.
Comment 4 Milutin Kristofic 2015-07-15 11:58:31 UTC
I am sorry there is not enough information to have P1 priority. Spellchecker is waiting for EventQ, but it doesn't hold anything. I would more investigate document holding in AWT-EQ. Are there sources of com.raelity.jvi. available online?
Comment 5 err 2015-07-15 15:20:27 UTC
(In reply to Milutin Kristofic from comment #4)
> I am sorry there is not enough information to have P1 priority.

Right. Without the messages.log from @arren it's hard to say...

> Spellchecker
> is waiting for EventQ, but it doesn't hold anything. I would more
> investigate document holding in AWT-EQ. Are there sources of
> com.raelity.jvi. available online?

Sure, jVi is a sourceforge project, https://sourceforge.net/projects/jvi/,
it has been primarily in maintenance mode for several years. There are
several thousands of jVi users and it doesn't really directly use document
locking. I'm suspicious of the "Velocity" plugin, or perhaps some
strange interaction between it and something else.

jVi certainly doesn't take any internal/private locks from the ViewHierarchy
code, which is where it is stuck. Notice that ViewHier is the process which is
holding the document read-lock causing the deadlock. ViewHier has been
involved in lots of deadlocks over the years, I'd have someone familiar with
that code take a look.
Comment 6 arren 2015-07-15 21:42:35 UTC
Created attachment 154661 [details]
messages.log

messages.log attached as requested. I see a useful exception in there.
Comment 7 arren 2015-07-15 21:46:17 UTC
Pertinent extract:

WARNING [org.netbeans.modules.editor.bracesmatching.MasterMatcher]: Origin offsets out of range, origin = [8464, 8468], caretOffset = 8463, lookahead
 = 129, searching backwards. Offending BracesMatcher: com.tsi.netbeans.modules.languages.velocity.editor.bracesmatching.VTLBracesMatcher@1e8758fa
WARNING [org.openide.filesystems.Ordering]: Not all children in / marked with the position attribute: [org-netbeans-modules-editor-java-JavaBracesMat
cher.shadow], but some are: [org-netbeans-modules-editor-bracesmatching-LegacyEssMatcher.instance, org-netbeans-modules-editor-bracesmatching-Default
Matcher.instance]
WARNING [org.netbeans.modules.editor.bracesmatching.MasterMatcher]: Origin offsets out of range, origin = [8414, 8418], caretOffset = 8413, lookahead
 = 79, searching backwards. Offending BracesMatcher: com.tsi.netbeans.modules.languages.velocity.editor.bracesmatching.VTLBracesMatcher@24851b1e
WARNING [org.netbeans.modules.editor.bracesmatching.MasterMatcher]: Origin offsets out of range, origin = [8414, 8418], caretOffset = 8413, lookahead
 = 79, searching backwards. Offending BracesMatcher: com.tsi.netbeans.modul
es.languages.velocity.editor.bracesmatching.VTLBracesMatcher@195515fc
WARNING [org.netbeans.modules.editor.bracesmatching.MasterMatcher]: Origin offsets out of range, origin = [8414, 8418], caretOffset = 8413, lookahead = 79, searching backwards. Offending BracesMatcher: com.tsi.netbeans.modules.languages.velocity.editor.bracesmatching.VTLBracesMatcher@6e2d1cf3
WARNING [org.netbeans.modules.editor.bracesmatching.MasterMatcher]: Origin offsets out of range, origin = [8416, 8420], caretOffset = 8415, lookahead = 81, searching backwards. Offending BracesMatcher: com.tsi.netbeans.modules.languages.velocity.editor.bracesmatching.VTLBracesMatcher@38f1b8dd
WARNING [org.netbeans.modules.java.source.parsing.JavacParser]: Javac returned startpos: 5,340 > endpos: -1
WARNING [com.raelity.jvi.core.MagicRedoOriginal]: docRemove ERROR: expectChar len = 12
WARNING [com.raelity.jvi.core.MagicRedoOriginal]: markRedoPosition ERROR: expectChar
WARNING [org.netbeans.api.editor.fold.FoldHierarchy]: Fold transaction not committed at unlock
SEVERE [global]
java.lang.IllegalStateException: No transaction in progress
        at org.netbeans.modules.editor.fold.FoldHierarchyExecution.clearActiveTransaction(FoldHierarchyExecution.java:668)
        at org.netbeans.modules.editor.fold.FoldHierarchyTransactionImpl.cancelled(FoldHierarchyTransactionImpl.java:214)
        at org.netbeans.modules.editor.fold.FoldHierarchyExecution.unlock(FoldHierarchyExecution.java:398)
        at org.netbeans.api.editor.fold.FoldHierarchy.unlock(FoldHierarchy.java:218)
        at org.netbeans.editor.CodeFoldingSideBar.getPaintInfo(CodeFoldingSideBar.java:493)
        at org.netbeans.editor.CodeFoldingSideBar.paintComponent(CodeFoldingSideBar.java:957)
        at javax.swing.JComponent.paint(JComponent.java:1046)
        at javax.swing.JComponent.paintChildren(JComponent.java:879)
Comment 8 err 2015-07-15 22:27:24 UTC
Actually, this looks pretty suspicious. It seems like the velocity plugin
might be breaking some locking rules...


INFO [org.netbeans.spi.lexer.MutableTextInput]: !!WARNING!! Missing READ-LOCK when accessing TokenHierarchy: input-source:org.netbeans.modules.editor.NbEditorDocument@480f0609, mimeType='text/x-velocity', kitClass=null, length=402, version=1, file=com.tsi.netbeans.modules.languages.velocity.VTLDataObject@4dd91cb6[/home/shevek/java/sablecc3/sablecc-core/src/main/resources/org/sablecc/experimental/ilexer.vm@c740b43a:4e61afc]
java.lang.Exception
	at org.netbeans.lib.lexer.TokenHierarchyOperation.ensureReadLocked(TokenHierarchyOperation.java:406)
	at org.netbeans.lib.lexer.TokenHierarchyOperation.tokenSequence(TokenHierarchyOperation.java:431)
	at org.netbeans.lib.lexer.TokenHierarchyOperation.tokenSequence(TokenHierarchyOperation.java:427)
	at org.netbeans.lib.lexer.TokenHierarchyOperation.embeddedTokenSequences(TokenHierarchyOperation.java:459)
	at org.netbeans.api.lexer.TokenHierarchy.embeddedTokenSequences(TokenHierarchy.java:265)
	at com.tsi.netbeans.modules.languages.velocity.editor.bracesmatching.VTLBracesMatcher.getTokenSequences(VTLBracesMatcher.java:184)
	at com.tsi.netbeans.modules.languages.velocity.editor.bracesmatching.VTLBracesMatcher.findOrigin(VTLBracesMatcher.java:60)
	at org.netbeans.modules.editor.bracesmatching.MasterMatcher$Result.findOrigin(MasterMatcher.java:857)
Comment 9 arren 2015-08-15 21:43:43 UTC
Thank you for finding the locking violation. So how do we get this fixed?
Comment 10 err 2015-08-16 14:30:57 UTC
(In reply to arren from comment #9)
> Thank you for finding the locking violation. So how do we get this fixed?

I would contact the velocity plugin author and ask him to comment on the analysis in this thread.
Comment 11 wjaeger 2015-08-17 07:55:08 UTC
(In reply to arren from comment #9)
> Thank you for finding the locking violation. So how do we get this fixed?

I can not really tell if the locking violation caused the editor to freeze, but I fixed it in version 2.2.5
Comment 12 err 2015-11-03 05:07:42 UTC
@arren

Did wjaeger's change fix your problem?