Bug 52038 - Indexer crashed
Summary: Indexer crashed
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M8   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-13 21:23 EST by Wassim Melhem CLA
Modified: 2004-02-18 13:08 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wassim Melhem CLA 2004-02-13 21:23:34 EST
Build: 3.0M7

I launched a runtime workbench in debug mode on an existing workspace 
containing two Hello world plug-ins.
When the runtime workbench appeared, I got the first stack pasted below in my 
log complaining about background indexer crashing.

In the threads view of my host workbench, two threads paused, when I 
pressed 'continue' on both of them.  The first thread dumped a stack to the 
console that is identical to the one I found in the log.  The second thread 
dumped an NPE.  It's the second stack pasted below.

Error Feb 13, 2004 21:06:32.281 Background Indexer Crash Recovery
java.lang.ArrayIndexOutOfBoundsException: 16777425
at org.eclipse.jdt.internal.core.index.impl.WordEntry.mapRefs
(WordEntry.java:136)
at org.eclipse.jdt.internal.core.index.impl.MergeFactory.mergeReferences
(MergeFactory.java:180)
at org.eclipse.jdt.internal.core.index.impl.MergeFactory.merge
(MergeFactory.java:87)
at org.eclipse.jdt.internal.core.index.impl.IndexImpl.merge(IndexImpl.java:221)
at org.eclipse.jdt.internal.core.index.impl.IndexImpl.save(IndexImpl.java:315)
at org.eclipse.jdt.internal.core.search.indexing.IndexManager.saveIndex
(IndexManager.java:450)
at org.eclipse.jdt.internal.core.search.indexing.AddJarFileToIndex.execute
(AddJarFileToIndex.java:176)
at org.eclipse.jdt.internal.core.search.processing.JobManager.run
(JobManager.java:344)
at java.lang.Thread.run(Thread.java:534)



java.lang.NullPointerException
at org.eclipse.jdt.internal.core.search.indexing.IndexManager.updateIndexState
(IndexManager.java:616)
	at 
org.eclipse.jdt.internal.core.search.indexing.IndexManager.rebuildIndex
(IndexManager.java:331)
	at org.eclipse.jdt.internal.core.search.indexing.IndexManager.getIndex
(IndexManager.java:125)
	at org.eclipse.jdt.internal.core.search.PatternSearchJob.getIndexes
(PatternSearchJob.java:103)
	at org.eclipse.jdt.internal.core.search.PatternSearchJob.execute
(PatternSearchJob.java:65)
	at 
org.eclipse.jdt.internal.core.search.processing.JobManager.performConcurrentJob
(JobManager.java:261)
	at org.eclipse.jdt.core.search.SearchEngine.searchAllTypeNames
(SearchEngine.java:825)
	at org.eclipse.jdt.internal.corext.util.AllTypesCache.search
(AllTypesCache.java:440)
	at 
org.eclipse.jdt.internal.corext.util.AllTypesCache$TypeCacher.doSearchTypes
(AllTypesCache.java:129)
	at org.eclipse.jdt.internal.corext.util.AllTypesCache$TypeCacher.run
(AllTypesCache.java:98)
Comment 1 Kent Johnson CLA 2004-02-17 14:18:02 EST
This is the code for the method:

private void updateIndexState(String indexName, Integer indexState) {
	getIndexStates(); // ensure the states are initialized
	if (indexState != null) {
		if (indexState.equals(indexStates.get(indexName))) return;
		indexStates.put(indexName, indexState);
	} else {
		if (!indexStates.containsKey(indexName)) return;
		indexStates.removeKey(indexName);
	}

	BufferedWriter writer = null;
	try {
		writer = new BufferedWriter(new FileWriter
(savedIndexNamesFile));
		Object[] keys = indexStates.keyTable;

'indexStates' cannot be null here since it wasn't null 5 lines above.

Likely a VM problem.
Comment 2 Wassim Melhem CLA 2004-02-17 17:05:56 EST
Unlikely to be VM-related.

It is possible for 'indexStates' to be null, because the if check is 
for 'indexState' (i.e. singular).
Comment 3 Kent Johnson CLA 2004-02-18 11:33:21 EST
Look at the then AND else blocks, both access indexStates... it cannot be null 
on a few lines later.
Comment 4 Wassim Melhem CLA 2004-02-18 12:36:11 EST
Please indicate exactly which line from your snippet corresponds to the line 
throwing the NPE, so I could try to figure out where the NPE could be coming 
from.  What I know is that I got an NPE and I have got the stack trace to 
prove it, so I'm not sure that closing it without further investigation is a 
good idea.
Comment 5 Kent Johnson CLA 2004-02-18 13:08:17 EST
Without further investigation? Did you even try to read thru the code in the 
stack trace?


The very first method called in updateIndexState is:
private void updateIndexState(String indexName, Integer indexState) {
	getIndexStates(); // ensure the states are initialized

Here's the code for it:

private SimpleLookupTable getIndexStates() {
	if (indexStates != null) return indexStates;

	this.indexStates = new SimpleLookupTable();
	char[] savedIndexNames = readIndexState();
	if (savedIndexNames.length > 0) {
		char[][] names = CharOperation.splitOn('\n', savedIndexNames);
		for (int i = 0, l = names.length; i < l; i++) {
			char[] name = names[i];
			if (name.length > 0)
				this.indexStates.put(new String(name), 
SAVED_STATE);
		}
	}
	return this.indexStates;
}

So how is indexStates null a few lines later?