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 85000

Summary: NB IDE frozen after ArrayIndexOutOfBoundsException
Product: editor Reporter: m_potociar <m_potociar>
Component: -- Other --Assignee: Miloslav Metelka <mmetelka>
Status: RESOLVED FIXED    
Severity: blocker CC: lhasik, pnejedly
Priority: P1 Keywords: THREAD
Version: 5.x   
Hardware: All   
OS: Windows XP   
Issue Type: DEFECT Exception Reporter:
Attachments: NB log file
Zipped log file with the exception
Zipped log file with the exception
Possible patch to be tested
stacktrace
unfortunatelly I was wrong. Deadlock appeared... I'm attaching thread dump
messages log + console output + thread dump

Description m_potociar 2006-09-15 14:54:22 UTC
While typing the code, suddenly AIOOBE was thrown for no apparent reason. NB IDE
stopped responding afterwards and I had to kill the process manually.

IMHO this is P1 because NB stopped responding and I lost my changes in the
edited file.
Comment 1 m_potociar 2006-09-15 14:55:09 UTC
Created attachment 34017 [details]
NB log file
Comment 2 Jan Pokorsky 2006-09-15 15:28:16 UTC
bug of draw engine? reassigning to editor
Comment 3 Miloslav Metelka 2006-09-15 23:10:25 UTC
I have searched both our and JDK bug databases but did not find any similar
problem. Do you have any idea how to reproduce the problem? Was that a specific
source that you could attach to the issue etc. ? Thanks in advance.
Comment 4 m_potociar 2006-09-19 15:29:33 UTC
I do not have any idea how to reproduce the problem in a deterministic way. It
however happened again (on a different source file, with new NB userdir). I am
attaching the log file again.
Comment 5 m_potociar 2006-09-19 15:30:24 UTC
Created attachment 34160 [details]
Zipped log file with the exception
Comment 6 m_potociar 2006-09-27 13:12:20 UTC
Now the exception occured when presing right arrow on the last character on the
line. Attaching the log again.
Comment 7 m_potociar 2006-09-27 13:16:22 UTC
Created attachment 34581 [details]
Zipped log file with the exception
Comment 8 m_potociar 2006-09-27 13:24:26 UTC
Again!!!

Currently it happened when I was trying to declare and initialize a private
field. So I typed something like:

private static final PolicyModelMarshaller defaultXmlMarshaller = new
XmlPolicyModelMarshaller(false)

When I typed the closing bracket ')' the exception occured. I would really
appreciate if somebody tried to explore the problem in more detail, because it
is pretty annoying if NB gets frozen and must be killed 2 times in 5 minutes and
all the new code gets lost again and again.

I am currenlty using build from 25/09/2006.
Comment 9 Miloslav Metelka 2006-09-27 17:33:47 UTC
The exception in the second log is different (similar to the one in the issue
#67757) but the two could possibly be related.
I'm still unable to reproduce and there is no direct indication what could cause
this :( The rendering code was not touched for a long time so it must be caused
by some related code. Or it could be a threading issue which is however
unlikely. One thing that could theoretically be possible could be that the
rendering fragment offset is computed from the Syntax object being used during
painting. The Syntax objects get acquired and released and if someone would
continue to use the Syntax after releasing it could possibly cause this problem.
Could you please test the attached patch for some time whether it makes any
difference? Thanks.

If the patch does not help please try to run the IDE with 
-J-Dnetbeans.debug.editor.draw=true -J-Dnetbeans.debug.editor.draw.fragment=true
it will output the fragments being rendered and it could give a clue why this
happens. Thanks.
Comment 10 Miloslav Metelka 2006-09-27 17:36:06 UTC
Created attachment 34600 [details]
Possible patch to be tested
Comment 11 Miloslav Metelka 2006-09-29 10:51:31 UTC
OK, I've applied the patch to the trunk. I've also simplified SegmentCache impl
to not do any caching as it's superflous with present JVMs:
Checking in libsrc/org/netbeans/editor/BaseDocument.java;
/cvs/editor/libsrc/org/netbeans/editor/BaseDocument.java,v  <--  BaseDocument.java
new revision: 1.133; previous revision: 1.132
done
Checking in libsrc/org/netbeans/editor/SegmentCache.java;
/cvs/editor/libsrc/org/netbeans/editor/SegmentCache.java,v  <--  SegmentCache.java
new revision: 1.6; previous revision: 1.5
Comment 12 Miloslav Metelka 2006-09-29 12:58:16 UTC
*** Issue 67757 has been marked as a duplicate of this issue. ***
Comment 13 Lukas Hasik 2006-10-03 18:04:09 UTC
Created attachment 34823 [details]
stacktrace
Comment 14 Lukas Hasik 2006-10-03 18:07:00 UTC
happend with build 061003
-the IDE didn't freeze
-not able to reproduce
-I resized IDE, Editor, Explorer. Then I edited a line of the document with errors.
Comment 15 Lukas Hasik 2006-10-03 18:12:58 UTC
Created attachment 34824 [details]
unfortunatelly I was wrong. Deadlock appeared... I'm attaching thread dump
Comment 16 Miloslav Metelka 2006-10-04 09:45:16 UTC
The deadlock seems strange, there is no thread that would hold the document's
read/write lock that the AWT waits on.
Marku and Lukasi, I'm wondering whether this could be caused by a particular JDK
version. Could you please test on 1.5.0_07 or 1.5.0_06? Thanks in advance.
Comment 17 Lukas Hasik 2006-10-04 10:28:52 UTC
It happened to me with 5.5 RC1 + jdk1.5.0_09-b01
I'm sorry but I will not to test with jdk1.5.0_06/7 it would be step back for
me. I don't know how to reproduce it :( 
Comment 18 m_potociar 2006-10-04 10:43:08 UTC
Hi Milo, currently I am using jdk1.5.0_08. I will try to switch to _07. Btw. I
didn't find a better way how to download older revision of JDK than to take the link

http://javashoplm.sun.com/ECom/docs/Welcome.jsp?StoreId=22&PartDetailId=jdk-1.5.0_08-oth-JPR&SiteId=JSC&TransactionId=noreg

and manualy modify "jdk-1.5.0_08" to "jdk-1.5.0_07".
Comment 19 Miloslav Metelka 2006-10-04 13:06:52 UTC
http://java.sun.com/products/archive/ could be used as well.
Comment 20 Jiri Prox 2006-10-09 08:09:48 UTC
Reproduced by another user on 

NB RC1
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b86) 
Comment 21 m_potociar 2006-10-09 15:15:22 UTC
I believe that this exception is connected to the issue. I was running NB5.5 RC1.

Attaching messages log, console output and thread dump.
Comment 22 m_potociar 2006-10-09 15:16:13 UTC
Created attachment 35042 [details]
messages log + console output + thread dump
Comment 23 Miloslav Metelka 2006-10-09 17:50:20 UTC
Thanks for the last dump.
I've noticed that the code in DrawEngine:1088 is executing finally code block so
it might be possible that there was an exception thrown inside the block before
the finally clause that was hidden by the exception thrown in the finally
clause. I'll make a patch that will do setting of a null buffer before the
finally clause. It is more correct to not attempt to continue rendering through
DrawGraphics if an exception occurs. That could help us to discover the original
exception if there is a one.
Comment 24 Miloslav Metelka 2006-10-09 18:19:04 UTC
Possible fix in trunk:
Checking in DrawGraphics.java;
/cvs/editor/libsrc/org/netbeans/editor/DrawGraphics.java,v  <--  DrawGraphics.java
new revision: 1.26; previous revision: 1.25
done
Checking in DrawEngine.java;
/cvs/editor/libsrc/org/netbeans/editor/DrawEngine.java,v  <--  DrawEngine.java
new revision: 1.46; previous revision: 1.45

Graphical diffs:
http://www.netbeans.org/source/browse/editor/libsrc/org/netbeans/editor/DrawGraphics.java.diff?r1=1.25&r2=1.26
http://www.netbeans.org/source/browse/editor/libsrc/org/netbeans/editor/DrawEngine.java.diff?r1=1.45&r2=1.46
Comment 25 Miloslav Metelka 2006-10-09 18:38:36 UTC
IMHO we could safely integrate the above patch into release55 as it should be
completely non-harming.
Comment 26 m_potociar 2006-10-09 20:20:56 UTC
+1 for integrating the patch into release55.

Also, if you have the patch in a form of binary jar, please let me know. Thanks.
Comment 27 Jan Lahoda 2006-10-10 14:35:06 UTC
The patch seems OK to me.
Comment 28 Miloslav Metelka 2006-10-10 15:08:41 UTC
Integrated the last fix into release55:

Checking in libsrc/org/netbeans/editor/DrawEngine.java;
/cvs/editor/libsrc/org/netbeans/editor/DrawEngine.java,v  <--  DrawEngine.java
new revision: 1.42.2.1.2.2; previous revision: 1.42.2.1.2.1
done
Checking in libsrc/org/netbeans/editor/DrawGraphics.java;
/cvs/editor/libsrc/org/netbeans/editor/DrawGraphics.java,v  <--  DrawGraphics.java
new revision: 1.22.2.1.2.2; previous revision: 1.22.2.1.2.1

Marking as fixed. If the problem would reappear please reopen the issue.
Comment 29 Jiri Prox 2006-10-11 09:37:26 UTC
*** Issue 86805 has been marked as a duplicate of this issue. ***
Comment 30 Miloslav Metelka 2006-10-11 10:13:20 UTC
Integrated into release55_dev:
Checking in libsrc/org/netbeans/editor/DrawEngine.java;
/cvs/editor/libsrc/org/netbeans/editor/DrawEngine.java,v  <--  DrawEngine.java
new revision: 1.42.2.1.2.1.14.1; previous revision: 1.42.2.1.2.1
done
Checking in libsrc/org/netbeans/editor/DrawGraphics.java;
/cvs/editor/libsrc/org/netbeans/editor/DrawGraphics.java,v  <--  DrawGraphics.java
new revision: 1.22.2.1.2.1.14.1; previous revision: 1.22.2.1.2.1