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.
Build: NetBeans IDE Dev (Build 200812180001) VM: Java HotSpot(TM) Client VM, 11.0-b16, Java(TM) SE Runtime Environment, 1.6.0_11-b03 OS: Windows XP, 5.1, x86 User Comments: GUEST: typing some #includes sreque: I performed an undo operation. sreque: Deleting text in a C file. The text was not in a valid C format. I was deleting entire lines at a time. ieising: Just coding. baffyofdaffy: Undoing changes one at a time using Local History sreque: I was editing text in a C File. I don't remember specifically what keystrokes I was hitting when it happened. Stacktrace: java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(System.java:0) at org.netbeans.editor.DocumentContent.copySpanChars(DocumentContent.java:280) at org.netbeans.editor.DocumentContent.getText(DocumentContent.java:185) at org.netbeans.editor.DocumentContent.getString(DocumentContent.java:169) at javax.swing.text.AbstractDocument.getText(AbstractDocument.java:757) at org.netbeans.modules.diff.builtin.visualizer.editable.EditableDiffView$RefreshDiffTask.computeDiff(EditableDiffView.java:985)
Created attachment 77377 [details] stacktrace
This issue has already 10 duplicates see http://statistics.netbeans.org/exceptions/detail.do?id=62240
vita, please: shouldn't AbstractDocument.getText() throw BadLocationException instead of ArrayIndexOutOfBoundsException? This one calls org.netbeans.editor.DocumentContent.getString() which checks arguments in checkBounds(offset, length, length()). Why would checkBounds allow to continue with wrong arguments and thus result in AIOOB?
Reassigning.
> vita, please: shouldn't AbstractDocument.getText() throw BadLocationException instead of ArrayIndexOutOfBoundsException? Yes, under normal circumstances it should. What you see here is a race condition, because Document.getText as well as any other method accessing document contents ought to be called under the document's readlock. There are different stacktraces duplicated to this issue, which means that there are different places in the IDE that violate this rule. Fix your EditableDiffView$RefreshDiffTask.computeDiff(EditableDiffView.java:985) and pass it to others. You should wrap your code in Document.render call.
fixing diff's part: cdev #4e2a7ad2eb6e reassigning to cnd to deal with the other reports
1) java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(System.java:0) at org.netbeans.editor.DocumentContent.copySpanChars(DocumentContent.java:280) at org.netbeans.editor.DocumentContent.getText(DocumentContent.java:185) at org.netbeans.editor.DocumentContent.getString(DocumentContent.java:169) at javax.swing.text.AbstractDocument.getText(AbstractDocument.java:757) at org.netbeans.modules.cnd.modelimpl.platform.FileBufferDoc.getInputStream(FileBufferDoc.java:143)
2) java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(System.java:0) at org.netbeans.editor.DocumentContent.copySpanChars(DocumentContent.java:280) at org.netbeans.editor.DocumentContent.getText(DocumentContent.java:185) at org.netbeans.editor.DocumentContent.getString(DocumentContent.java:169) at javax.swing.text.AbstractDocument.getText(AbstractDocument.java:757) at org.netbeans.modules.cnd.editor.parser.CppFile.startParsing(CppFile.java:165) at org.netbeans.modules.cnd.editor.parser.CppFile.startParsing(CppFile.java:136) at org.netbeans.modules.cnd.editor.parser.CppMetaModel$2.run(CppMetaModel.java:176) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:561) at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:986)
fixed: http://hg.netbeans.org/cnd-main?cmd=changeset;node=1c28d503a1c9 http://hg.netbeans.org/cnd-main?cmd=changeset;node=3ba40c01291a
Integrated into 'main-golden', will be available in build *200909181401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/1c28d503a1c9 User: Vladimir Voskresensky <vv159170@netbeans.org> Log: fixing IZ#159167: ArrayIndexOutOfBoundsException at java.lang.System.arraycopy
Integrated into 'main-golden', will be available in build *200909211401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/4e2a7ad2eb6e User: Ondrej Vrabec <ovrabec@netbeans.org> Log: #159167 - ArrayIndexOutOfBoundsException at java.lang.System.arraycopy getting document contents under a read lock