Bug 181349 - ArrayIndexOutOfBoundsException while editing Java code
Summary: ArrayIndexOutOfBoundsException while editing Java code
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-05 19:54 EDT by Walter Harley CLA
Modified: 2007-04-27 11:37 EDT (History)
3 users (show)

See Also:


Attachments
zipped log file (5.82 KB, application/octet-stream)
2007-04-05 19:55 EDT, Walter Harley CLA
no flags Details
Proposed patch (2.45 KB, patch)
2007-04-19 09:48 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Walter Harley CLA 2007-04-05 19:54:22 EDT
I was making some minor changes to some Java code, when all of a sudden I got an error popup.  Clicking OK simply resulted in a never-ending chain of errors, so there was no way to exit the application except to kill the process.

I will attach an error log showing the whole sequence.  The initial error seems to be this one:

!ENTRY org.eclipse.jdt.core 4 4 2007-04-05 16:39:14.947
!MESSAGE Could not retrieve declared methods
!STACK 0
java.lang.ArrayIndexOutOfBoundsException: 15
	at org.eclipse.jdt.internal.compiler.util.HashtableOfPackage.get(HashtableOfPackage.java:56)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getPackage0(LookupEnvironment.java:874)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getCachedType(LookupEnvironment.java:856)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromCompoundName(LookupEnvironment.java:976)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromConstantPoolName(LookupEnvironment.java:1002)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromSignature(LookupEnvironment.java:1056)
	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createFields(BinaryTypeBinding.java:336)
	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.cachePartsFrom(BinaryTypeBinding.java:313)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:599)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:578)
	at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:275)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:102)
	at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:43)
	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:97)
	at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.resolve(ParameterizedTypeBinding.java:818)
	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:111)
	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveTypesFor(BinaryTypeBinding.java:891)
	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.methods(BinaryTypeBinding.java:874)
	at org.eclipse.jdt.core.dom.TypeBinding.getDeclaredMethods(TypeBinding.java:266)
	at org.eclipse.jdt.internal.corext.dom.Bindings.findOverriddenMethodInType(Bindings.java:423)
	at org.eclipse.jdt.internal.corext.dom.Bindings.findOverriddenMethodInHierarchy(Bindings.java:440)
	at org.eclipse.jdt.internal.corext.dom.Bindings.findOverriddenMethod(Bindings.java:474)
	at org.eclipse.jdt.ui.OverrideIndicatorLabelDecorator.findInHierarchyWithAST(OverrideIndicatorLabelDecorator.java:179)
	at org.eclipse.jdt.ui.OverrideIndicatorLabelDecorator.getOverrideIndicators(OverrideIndicatorLabelDecorator.java:154)
	at org.eclipse.jdt.ui.OverrideIndicatorLabelDecorator.computeAdornmentFlags(OverrideIndicatorLabelDecorator.java:129)
	at org.eclipse.jdt.ui.OverrideIndicatorLabelDecorator.decorate(OverrideIndicatorLabelDecorator.java:261)
	at org.eclipse.ui.internal.decorators.LightweightDecoratorDefinition.decorate(LightweightDecoratorDefinition.java:259)
	at org.eclipse.ui.internal.decorators.LightweightDecoratorManager$LightweightRunnable.run(LightweightDecoratorManager.java:71)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.runtime.Platform.run(Platform.java:850)
	at org.eclipse.ui.internal.decorators.LightweightDecoratorManager.decorate(LightweightDecoratorManager.java:336)
	at org.eclipse.ui.internal.decorators.LightweightDecoratorManager.getDecorations(LightweightDecoratorManager.java:322)
	at org.eclipse.ui.internal.decorators.DecorationScheduler$1.ensureResultCached(DecorationScheduler.java:363)
	at org.eclipse.ui.internal.decorators.DecorationScheduler$1.run(DecorationScheduler.java:325)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)


The errors in the log after that reflect various other threads and tasks running into the same underlying array bounds exception.  That is, the deepest two levels of stack are the same in all the exceptions, but the top of the stack varies.

The reason for the endless string of exceptions seems to be that when a message box is dismissed, the editor window gets reactivated, resulting in a call to JavaEditor.updateOccurrenceAnnotations(), which tries to read the AST and encounters the error again, putting up another message box ad infinitum.

I'm marking this "major" because it rendered the app unusable and I had to kill it with the task manager.  However, I doubt it is easily reproducible.
Comment 1 Walter Harley CLA 2007-04-05 19:55:30 EDT
Created attachment 63129 [details]
zipped log file
Comment 2 Walter Harley CLA 2007-04-05 19:57:07 EDT
Forgot to say: this is being reported against I20070403-1110.
Comment 3 Philipe Mulet CLA 2007-04-06 07:01:08 EDT
This would indicate a case where keyTable and valueTable are out of sync. Looking at the code I don't see this being possible, unless some concurrency is occurring.

Feels like possible is shared DOM AST is being used by various threads, and are lazily populated, as implied by:

org.eclipse.jdt.core.dom.TypeBinding.getDeclaredMethods(TypeBinding.java:266)
Comment 4 Philipe Mulet CLA 2007-04-06 07:03:12 EDT
First thinking is that the DOM AST should be synchronized.
Comment 5 Kent Johnson CLA 2007-04-09 12:58:54 EDT
Olivier - please look into protecting the DOM calls to prevent concurrent accesses to Binary type bindings.
Comment 6 Philipe Mulet CLA 2007-04-10 07:12:05 EDT
Feels like in 3.4, we want to allow compiler to use concurrency (to exploit multicore processors), so some synchronization may occur at that level.
Until so, we have this weakness (which we had since day-1).

Need to be careful to avoid introducing deadlocks.
Comment 7 Olivier Thomann CLA 2007-04-19 09:45:36 EDT
I propose to synchronize the getDeclaredMethods(), getDeclaredFields(), ... methods.
Comment 8 Olivier Thomann CLA 2007-04-19 09:48:03 EDT
Created attachment 64309 [details]
Proposed patch

Jérôme, what do you think?
Comment 9 Jerome Lanneluc CLA 2007-04-19 10:08:53 EDT
Just being paranoid: are we certain that we don't call out from any synchronized methods ?
Comment 10 Olivier Thomann CLA 2007-04-19 10:17:26 EDT
I could not find a case where we do.
Comment 11 Jerome Lanneluc CLA 2007-04-19 10:18:43 EDT
Then the patch looks good to me.
Comment 12 Olivier Thomann CLA 2007-04-19 10:21:29 EDT
Released for 3.3M7.
Comment 13 Maxime Daniel CLA 2007-04-27 11:37:55 EDT
Verified for 3.3 M7 using source code v_751.
Checked that the patch was applied.