Community
Participate
Working Groups
Build Identifier: 20100617-1415 Error log reports a mess of errors on opening one project, with the first one being java.lang.ArrayIndexOutOfBoundsException: 42 at org.eclipse.jdt.internal.core.search.indexing.IndexManager.writeSavedIndexNamesFile(IndexManager.java:955) at org.eclipse.jdt.internal.core.search.indexing.IndexManager.updateIndexState(IndexManager.java:894) at org.eclipse.jdt.internal.core.search.indexing.IndexManager.rebuildIndex(IndexManager.java:553) at org.eclipse.jdt.internal.core.search.indexing.IndexManager.getIndex(IndexManager.java:237) at org.eclipse.jdt.internal.core.search.indexing.IndexManager.getIndexes(IndexManager.java:312) at org.eclipse.jdt.internal.core.search.PatternSearchJob.getIndexes(PatternSearchJob.java:81) at org.eclipse.jdt.internal.core.search.PatternSearchJob.ensureReadyToRun(PatternSearchJob.java:50) at org.eclipse.jdt.internal.core.search.processing.JobManager.performConcurrentJob(JobManager.java:174) Reproducible: Couldn't Reproduce Steps to Reproduce: n/a
Created attachment 175151 [details] error details error details from exception, with source code deleted
Checking the source code for IndexManager, it looks to be some kind of concurrency issue. 1. writeSavedIndexNamesFile traverses both indexStates.keyTable and indexStates.valueTable using a length taken from only one of them. So any concurrent modification of indexStates can get an exception at lines 955 (if the update happens between line 952 and 953). 2. writeSavedIndexNamesFile has all paths to it synchronised. 3. getIndexStates is unsynchronised, and called from public function that are a mixture of sync and unsync. In particular, computeIndex and ensureIndexExists appear to be called from other threads.
(In reply to comment #2) Thanks for the analysis. getIndexStates() could potentially create a problem only in the beginning of the execution. It does put in the table only for the first time and from the next time onwards, it just returns. Did you run into the problem at the startup?
(In reply to comment #3) Yes, the error occurred on startup.
This is what I think is happening. A call to getIndexStates() from computeIndexLocation() or ensureIndexExists() is trying to build the indexStates. The subsequent call through some other synchronized function thinks the indexStates is initialized and starts using the table and running into some inconsistency during the initialization. Though we could try to synchronize just the block of indexStates initialization, we could end up with similar problem in computeIndexLocation() or ensureIndexExists(). Hence, I think the best way to fix this could be make both these functions synchronized.
Created attachment 175368 [details] Proposed patch Made both computeIndexLocation() and ensureIndexExists() synchronized. I don't have any test for this. Srikanth, Could you please review? TIA.
Srikanth, Can you please review this patch? The patch is very small and doesn't have any test. TIA.
(In reply to comment #7) > Srikanth, Can you please review this patch? The patch is very small and doesn't > have any test. TIA. Patch looks good.
Released on HEAD.
Verified for 3.7M2 using code inspection
*** Bug 215033 has been marked as a duplicate of this bug. ***