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 108889 - AIOOBE and AE during editing
Summary: AIOOBE and AE during editing
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Lexer (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: issues@editor
URL:
Keywords: RANDOM
: 109701 109935 109946 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-07-04 16:16 UTC by Martin Krauskopf
Modified: 2007-07-17 19:08 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
exceptions.txt (46.04 KB, text/plain)
2007-07-04 16:16 UTC, Martin Krauskopf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Krauskopf 2007-07-04 16:16:03 UTC
I think that after I cut some text from Ruby test. Hard to get rid of it. Attaching relevant part of log.
Todays fresh build, Linux.
Comment 1 Martin Krauskopf 2007-07-04 16:16:39 UTC
Created attachment 44714 [details]
exceptions.txt
Comment 2 Torbjorn Norbye 2007-07-04 16:46:23 UTC
Do you have any ideas how to reproduce this? Do you remember which file you were editing? Can you attach it? (I'm curious to know if it has any heredocs 
(<<FOO) in it.
Comment 3 Martin Krauskopf 2007-07-04 17:18:14 UTC
Unfortunately no. I did some larger refactoring and create some tests in debug-commons project. It happened to me with
this file:

  svn cat svn://rubyforge.org/var/svn/debug-commons/trunk/test-base/stepping_breakpoints_test.rb

I did some commenting/uncommenting, running test, editing externally, back to NetBeans editor, ... so do not have steps :)
Let me know if I may enable some logging or whatever...
Comment 4 Torbjorn Norbye 2007-07-04 17:18:47 UTC
I can reproduce this with the following unit test (append to the bottom of org.netbeans.modules.ruby.BracketCompleterTest in ruby/editing/test/unit/src

    public void test108889() throws Exception {
        // Reproduce 108889: AIOOBE and AE during editing
        insertChar("x = %q((^))", 'a', "x = %q((a^))");
    }

If I try this editing scenario by hand, it doesn't throw the exceptions.  (The above test will place the caret at "^" in the first string, insert the character a, and 
then make sure the resulting document is the same as the second string, with the caret position being where "^" is shown (in both cases, the "^" is removed 
from the string before inserting/comparing with the document.)
Comment 5 Torbjorn Norbye 2007-07-04 17:46:01 UTC
I've checked in the unit test (disabled in xtest but there nevertheless) so just open BracketCompleterTest and run it, you'll get the failure.

I don't know if this is a lexer bug, or if the Ruby lexer is returning some data that the lexer is not expecting/allowing.

I'm reassigning to the lexer for an initial evaluation. This by the way looks similar to issue 107922, but that's filed as a P3 and I think Martin is right that this 
is a P2.  This might also be related to issue 108813 (a P1); in issue 108347 the user observd both problems (the exception as well as the infinite tokenlist 
loop).
Comment 6 Torbjorn Norbye 2007-07-04 17:57:27 UTC
This is possibly/likely a duplicate of 108617
Comment 7 Torbjorn Norbye 2007-07-11 23:39:30 UTC
I'm getting this exception in lots of other scenarios too so it's getting really severe. It's blocking instant-renaming of block vars for example.

Bumping up the priority.
Comment 8 Torbjorn Norbye 2007-07-16 02:53:37 UTC
*** Issue 109701 has been marked as a duplicate of this issue. ***
Comment 9 Torbjorn Norbye 2007-07-17 00:57:50 UTC
*** Issue 109935 has been marked as a duplicate of this issue. ***
Comment 10 Torbjorn Norbye 2007-07-17 03:54:25 UTC
*** Issue 109946 has been marked as a duplicate of this issue. ***
Comment 11 Miloslav Metelka 2007-07-17 14:40:29 UTC
I'm able to reproduce by using the BracketCompleterTest and I hope to have a fix ready today's evening.
Comment 12 Miloslav Metelka 2007-07-17 16:10:48 UTC
I have committed a fix for AIOOBE.
I would like to add a test for this issue but I need to create a special language that will have an extra lookahead so
that the specific conditions get triggered.

Checking in TokenListUpdater.java;
/cvs/lexer/src/org/netbeans/lib/lexer/inc/TokenListUpdater.java,v  <--  TokenListUpdater.java
new revision: 1.13; previous revision: 1.12
Comment 13 Torbjorn Norbye 2007-07-17 19:08:35 UTC
Great - the unit tests are passing now! Thanks!!

I'm seeing one more problem though, which I think is similar to the scenario used in several of the bugs I closed as duplicates of this one.  

If you create an empty Ruby script (or just create a Ruby Application and replace the text in the file that is opened) with the following in it:

[1,2,3].each { |foo|
  puts foo
}

Place the caret on the first instance of "foo" and hit Command-R (Ctrl-R) to go into instant renaming of foo.

Press "a". For me, it triggers the following exception which looks similar to the original problem:

java.lang.ArrayIndexOutOfBoundsException: 64
	at org.netbeans.lib.lexer.LanguageOperation.tokenValidator(LanguageOperation.java:164)
	at org.netbeans.lib.lexer.inc.TokenListUpdater.update(TokenListUpdater.java:252)
	at org.netbeans.lib.lexer.TokenHierarchyOperation.textModified(TokenHierarchyOperation.java:277)
	at org.netbeans.spi.lexer.TokenHierarchyControl.textModified(TokenHierarchyControl.java:81)
	at org.netbeans.lib.lexer.inc.DocumentInput.modified(DocumentInput.java:115)
	at org.netbeans.lib.lexer.inc.DocumentInput.insertUpdate(DocumentInput.java:104)
	at org.netbeans.lib.editor.util.swing.PriorityDocumentListenerList.insertUpdate(PriorityDocumentListenerList.java:48)
	at javax.swing.text.AbstractDocument.fireInsertUpdate(AbstractDocument.java:184)
	at org.netbeans.editor.BaseDocument.fireInsertUpdate(BaseDocument.java:1342)
	at org.netbeans.editor.BaseDocument.insertString(BaseDocument.java:599)
	at org.netbeans.modules.gsf.GsfEditorKitFactory$GsfEditorKit$GsfDefaultKeyTypedAction.replaceSelection(GsfEditorKitFactory.java:485)
	at org.netbeans.editor.BaseKit$DefaultKeyTypedAction.actionPerformed(BaseKit.java:1013)
	at org.netbeans.editor.ext.ExtKit$ExtDefaultKeyTypedAction.actionPerformed(ExtKit.java:886)
	at org.netbeans.modules.gsf.GsfEditorKitFactory$GsfEditorKit$GsfDefaultKeyTypedAction.actionPerformed(GsfEditorKitFactory.java:420)
	at org.netbeans.editor.BaseAction.actionPerformed(BaseAction.java:266)

Do you want me to reopen this one, or create a new issue for this?