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 159167 - ArrayIndexOutOfBoundsException at java.lang.System.arraycopy
Summary: ArrayIndexOutOfBoundsException at java.lang.System.arraycopy
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Vladimir Voskresensky
URL: http://statistics.netbeans.org/except...
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-25 19:34 UTC by baffyofdaffy
Modified: 2009-09-21 21:46 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 62240


Attachments
stacktrace (859 bytes, text/plain)
2009-02-25 19:35 UTC, baffyofdaffy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description baffyofdaffy 2009-02-25 19:34:57 UTC
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)
Comment 1 baffyofdaffy 2009-02-25 19:35:05 UTC
Created attachment 77377 [details]
stacktrace
Comment 2 Exceptions Reporter 2009-03-17 14:56:05 UTC
This issue has already 10 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=62240
Comment 3 Ondrej Vrabec 2009-04-20 15:15:20 UTC
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?
Comment 4 Peter Pis 2009-09-14 10:17:59 UTC
Reassigning.
Comment 5 Vitezslav Stejskal 2009-09-16 15:17:59 UTC
> 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.
Comment 6 Ondrej Vrabec 2009-09-17 11:41:21 UTC
fixing diff's part: cdev #4e2a7ad2eb6e

reassigning to cnd to deal with the other reports
Comment 7 Vladimir Voskresensky 2009-09-17 12:11:26 UTC
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)
Comment 8 Vladimir Voskresensky 2009-09-17 12:13:00 UTC
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)
Comment 10 Quality Engineering 2009-09-18 22:24:38 UTC
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
Comment 11 Quality Engineering 2009-09-21 21:46:36 UTC
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