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 225052 - IDE got frozen after many Undo(s)
Summary: IDE got frozen after many Undo(s)
Status: RESOLVED DUPLICATE of bug 225087
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 7.3
Hardware: PC Linux
: P1 normal (vote)
Assignee: Miloslav Metelka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-18 09:48 UTC by Tomas Mysik
Modified: 2013-01-22 13:44 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
thread dump (42.97 KB, text/plain)
2013-01-18 09:48 UTC, Tomas Mysik
Details
thread dump (16.42 KB, text/plain)
2013-01-21 15:06 UTC, Jiri Prox
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Mysik 2013-01-18 09:48:41 UTC
Created attachment 130352 [details]
thread dump

I was invoking "Undo" quite many times in a row, via keyboard.

Not sure about proper component, please evaluate. Thanks a lot.

Product Version: NetBeans IDE Dev (Build 20130110-f9c322a6c6f2)
Java: 1.6.0_38; Java HotSpot(TM) 64-Bit Server VM 20.13-b02
Runtime: Java(TM) SE Runtime Environment 1.6.0_38-b05
System: Linux version 3.5.0-22-generic running on amd64; UTF-8; cs_CZ (nb)
Comment 1 Jan Lahoda 2013-01-21 09:53:01 UTC
What I can infer from the thread dump: BaseDocument.find is in the "search backwards" mode, while the finder passed to it is a forward finder. This seems to cause an infinite loop in BaseDocument.find (not really surprising and there is probably not much that could be fixed on this layer - or more precisely, the results would not be correct anyway, even if the infinite loop would be stopped). So the question is why the backwards search mode. The backwards mode is used if the search-limit < search-start. getRowFirstNonWhite basically does:
Element lineElement = <given-line>
find(..., lineElement.getStartOffset(), lineElement.getEndOffset() - 1)
//           ==search-start==         ,    ==search-limit==

So, it seems that:
lineElement.getEndOffset() - 1 < lineElement.getStartOffset()
which should not happen, as far as I can tell. So the only thing that comes to my mind is that start/end Positions got messed up during an undo or redo (a redo is being run on the thread dump, BTW).

It might (but needn't) be related to bug #225087.
Comment 2 David Strupl 2013-01-21 10:38:46 UTC
Several consecutive thread dumps when this happened to me:


java.lang.Thread.State: RUNNABLE
    at org.netbeans.modules.editor.lib2.document.EditorDocumentContent.getChars(EditorDocumentContent.java:225)
	- locked <0x000000012ce396d8> (a org.netbeans.modules.editor.lib2.document.EditorDocumentContent)
	at javax.swing.text.AbstractDocument.getText(AbstractDocument.java:812)
	at org.netbeans.editor.BaseDocument.find(BaseDocument.java:1248)
	at org.netbeans.editor.Utilities.getFirstNonWhiteFwd(Utilities.java:497)
	at org.netbeans.editor.Utilities.getRowFirstNonWhite(Utilities.java:228)
	at org.netbeans.modules.editor.hints.AnnotationHolder.updateHighlightsOnLine(AnnotationHolder.java:822)
	at org.netbeans.modules.editor.hints.AnnotationHolder.updateHighlightsOnLine(AnnotationHolder.java:815)
	at org.netbeans.modules.editor.hints.AnnotationHolder.setErrorDescriptionsImpl(AnnotationHolder.java:1106)
	- locked <0x000000012ce4af40> (a org.netbeans.modules.editor.hints.AnnotationHolder)
	at org.netbeans.modules.editor.hints.AnnotationHolder.access$1900(AnnotationHolder.java:123)


 java.lang.Thread.State: RUNNABLE
	at javax.swing.text.AbstractDocument.getText(AbstractDocument.java:812)
	at org.netbeans.editor.BaseDocument.find(BaseDocument.java:1248)
	at org.netbeans.editor.Utilities.getFirstNonWhiteFwd(Utilities.java:497)
	at org.netbeans.editor.Utilities.getRowFirstNonWhite(Utilities.java:228)
	at org.netbeans.modules.editor.hints.AnnotationHolder.updateHighlightsOnLine(AnnotationHolder.java:822)
	at org.netbeans.modules.editor.hints.AnnotationHolder.updateHighlightsOnLine(AnnotationHolder.java:815)
	at org.netbeans.modules.editor.hints.AnnotationHolder.setErrorDescriptionsImpl(AnnotationHolder.java:1106)
	- locked <0x000000012ce4af40> (a org.netbeans.modules.editor.hints.AnnotationHolder)
	at org.netbeans.modules.editor.hints.AnnotationHolder.access$1900(AnnotationHolder.java:123)

java.lang.Thread.State: RUNNABLE
	at javax.swing.text.AbstractDocument.getText(AbstractDocument.java:812)
	at org.netbeans.editor.BaseDocument.find(BaseDocument.java:1248)
	at org.netbeans.editor.Utilities.getFirstNonWhiteFwd(Utilities.java:497)
	at org.netbeans.editor.Utilities.getRowFirstNonWhite(Utilities.java:228)
	at org.netbeans.modules.editor.hints.AnnotationHolder.updateHighlightsOnLine(AnnotationHolder.java:822)
	at org.netbeans.modules.editor.hints.AnnotationHolder.updateHighlightsOnLine(AnnotationHolder.java:815)
	at org.netbeans.modules.editor.hints.AnnotationHolder.setErrorDescriptionsImpl(AnnotationHolder.java:1106)
	- locked <0x000000012ce4af40> (a org.netbeans.modules.editor.hints.AnnotationHolder)
	at org.netbeans.modules.editor.hints.AnnotationHolder.access$1900(AnnotationHolder.java:123)

java.lang.Thread.State: RUNNABLE
	at javax.swing.text.AbstractDocument.getText(AbstractDocument.java:812)
	at org.netbeans.editor.BaseDocument.find(BaseDocument.java:1248)
	at org.netbeans.editor.Utilities.getFirstNonWhiteFwd(Utilities.java:497)
	at org.netbeans.editor.Utilities.getRowFirstNonWhite(Utilities.java:228)
	at org.netbeans.modules.editor.hints.AnnotationHolder.updateHighlightsOnLine(AnnotationHolder.java:822)
	at org.netbeans.modules.editor.hints.AnnotationHolder.updateHighlightsOnLine(AnnotationHolder.java:815)
	at org.netbeans.modules.editor.hints.AnnotationHolder.setErrorDescriptionsImpl(AnnotationHolder.java:1106)
	- locked <0x000000012ce4af40> (a org.netbeans.modules.editor.hints.AnnotationHolder)
	at org.netbeans.modules.editor.hints.AnnotationHolder.access$1900(AnnotationHolder.java:123)

java.lang.Thread.State: RUNNABLE
	at org.netbeans.editor.BaseDocument.find(BaseDocument.java:1255)
	at org.netbeans.editor.Utilities.getFirstNonWhiteFwd(Utilities.java:497)
	at org.netbeans.editor.Utilities.getRowFirstNonWhite(Utilities.java:228)
	at org.netbeans.modules.editor.hints.AnnotationHolder.updateHighlightsOnLine(AnnotationHolder.java:822)
	at org.netbeans.modules.editor.hints.AnnotationHolder.updateHighlightsOnLine(AnnotationHolder.java:815)
	at org.netbeans.modules.editor.hints.AnnotationHolder.setErrorDescriptionsImpl(AnnotationHolder.java:1106)
	- locked <0x000000012ce4af40> (a org.netbeans.modules.editor.hints.AnnotationHolder)
	at org.netbeans.modules.editor.hints.AnnotationHolder.access$1900(AnnotationHolder.java:123)

java.lang.Thread.State: RUNNABLE
	at org.netbeans.modules.editor.lib2.document.EditorDocumentContent.getChars(EditorDocumentContent.java:225)
	- locked <0x000000012ce396d8> (a org.netbeans.modules.editor.lib2.document.EditorDocumentContent)
	at javax.swing.text.AbstractDocument.getText(AbstractDocument.java:812)
	at org.netbeans.editor.BaseDocument.find(BaseDocument.java:1248)
	at org.netbeans.editor.Utilities.getFirstNonWhiteFwd(Utilities.java:497)
	at org.netbeans.editor.Utilities.getRowFirstNonWhite(Utilities.java:228)
	at org.netbeans.modules.editor.hints.AnnotationHolder.updateHighlightsOnLine(AnnotationHolder.java:822)
	at org.netbeans.modules.editor.hints.AnnotationHolder.updateHighlightsOnLine(AnnotationHolder.java:815)
	at org.netbeans.modules.editor.hints.AnnotationHolder.setErrorDescriptionsImpl(AnnotationHolder.java:1106)
	- locked <0x000000012ce4af40> (a org.netbeans.modules.editor.hints.AnnotationHolder)
	at org.netbeans.modules.editor.hints.AnnotationHolder.access$1900(AnnotationHolder.java:123)
Comment 3 Jan Lahoda 2013-01-21 11:05:32 UTC
I was also thinking about a possibility that the Positions would not be updated yet when insertUpdate was invoked, but from the David's stack traces it seems it happened outside any document modification (is that correct?).
Comment 4 Jan Lahoda 2013-01-21 12:05:24 UTC
Tomas, David, any chance you would be running with assertions disabled? I have found a bug related to disabled assertions:
http://netbeans.org/bugzilla/show_bug.cgi?id=225133

This is thrown during an undo, and the editor is not in a good shape after that. I was not able to reproduce the infinite loop, but I would not be surprised if it would be caused by that exception. BTW, if running with assertions disabled, could you please check messages.log for exceptions? Thanks.
Comment 5 Tomas Mysik 2013-01-21 13:35:16 UTC
I think I have assertions disabled (-J-da).
Comment 6 David Strupl 2013-01-21 14:19:29 UTC
I am getting this exception:

SEVERE [global]
java.lang.IndexOutOfBoundsException: (offset=237 + length=1)=238 > length()=141
	at org.netbeans.modules.editor.lib2.document.CharContent.removeText(CharContent.java:141)
	at org.netbeans.modules.editor.lib2.document.EditorDocumentContent.removeEdit(EditorDocumentContent.java:172)
	at org.netbeans.modules.editor.lib2.document.ContentEdit$InsertEdit.undo(ContentEdit.java:215)
	at org.netbeans.editor.BaseDocumentEvent.undo(BaseDocumentEvent.java:281)
	at org.netbeans.editor.GuardedDocumentEvent.undo(GuardedDocumentEvent.java:72)
	at org.netbeans.modules.editor.lib2.document.StableCompoundEdit.undo(StableCompoundEdit.java:93)
	at org.netbeans.editor.BaseDocument$AtomicCompoundEdit.undo(BaseDocument.java:2179)
	at org.openide.text.StableCompoundEdit.undo(StableCompoundEdit.java:93)
	at org.openide.text.WrapUndoEdit.undo(WrapUndoEdit.java:93)
	at org.openide.awt.UndoRedo$Manager.undoTo(UndoRedo.java:230)
	at org.openide.awt.UndoRedo$Manager.undo(UndoRedo.java:200)
	at org.openide.text.UndoRedoManager.access$301(UndoRedoManager.java:98)
	at org.openide.text.UndoRedoManager$DocLockedRun.run(UndoRedoManager.java:658)
	at org.netbeans.editor.GuardedDocument.runAtomic(GuardedDocument.java:317)
	at org.openide.text.UndoRedoManager$DocLockedRun.<init>(UndoRedoManager.java:631)
	at org.openide.text.UndoRedoManager$DocLockedRun.<init>(UndoRedoManager.java:623)
	at org.openide.text.UndoRedoManager$DocLockedRun.<init>(UndoRedoManager.java:619)
	at org.openide.text.UndoRedoManager.undo(UndoRedoManager.java:437)
	at org.netbeans.core.multiview.MultiViewPeer$DelegateUndoRedo.undo(MultiViewPeer.java:822)
	at org.openide.actions.UndoAction.performAction(UndoAction.java:186)
	at org.openide.util.actions.CallableSystemAction$1.run(CallableSystemAction.java:129)


BUT I think that when this exception happens the infinite loop does not happen! ;-)
Comment 7 David Strupl 2013-01-21 14:21:06 UTC
And BTW I am able to reproduce (both the exception and the hang) ... At least I think I am able to reproduce ...
Comment 8 Jiri Prox 2013-01-21 15:05:49 UTC
I happened to me as well, when trying to reproduce issue 225087.

System Info: 
  Product Version         = NetBeans IDE Dev (Build 20130121-35c327d5a6d6) (#35c327d5a6d6)
  Operating System        = Windows 7 version 6.1 running on amd64
  Java; VM; Vendor        = 1.7.0_11; Java HotSpot(TM) 64-Bit Server VM 23.6-b04; Oracle Corporation
  Runtime                 = Java(TM) SE Runtime Environment 1.7.0_11-b21
  Java Home               = C:\PROGRA~1\Java\JDK17~2.0_1\jre
  System Locale; Encoding = en_US (nb); Cp1250
  Home Directory          = C:\Users\jprox
  Current Directory       = D:\nbsrc\jet-main\nbbuild\netbeans\bin
  User Directory          = C:\Users\jprox\AppData\Roaming\NetBeans\dev
  Cache Directory         = C:\Users\jprox\AppData\Local\NetBeans\Cache\dev

assertions were disabled

thread dump is attached
Comment 9 Jiri Prox 2013-01-21 15:06:20 UTC
Created attachment 130452 [details]
thread dump
Comment 10 Jan Lahoda 2013-01-21 15:33:24 UTC
(In reply to comment #7)
> And BTW I am able to reproduce (both the exception and the hang) ... At least I
> think I am able to reproduce ...

So, could you please try to remove the assert (on "openide.text/src/org/openide/text/UndoRedoManager.java:397", keep the "addEdit" invocation) and try to reproduce the hang? That would help to find out if it is related or not.

I unfortunately was not able to reproduce the hang.

Thanks.
Comment 11 David Strupl 2013-01-22 09:14:44 UTC
After I have removed the assert I am no longer able to reproduce the hang.
Comment 12 Jan Lahoda 2013-01-22 09:17:10 UTC
Ok, thanks. Almost surely duplicate of bug #225087.

*** This bug has been marked as a duplicate of bug 225087 ***
Comment 13 Jiri Prox 2013-01-22 13:44:46 UTC
Removing the keyword - the issue 225087 is HR fix candidate as well