Bug 102754

Summary: [NPE] caused by CPPMethod#getVisibility() line: 143 when indexing Mozilla in Linux
Product: [Tools] CDT Reporter: Devin Steffler <devinsteffler.lists>
Component: cdt-coreAssignee: Andrew Niefer <aniefer>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: aniefer, john.camelon
Version: 3.0Keywords: contributed
Target Milestone: 3.0 RC2   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
fix for this PR bjorn.freeman-benson: iplog+

Description Devin Steffler CLA 2005-07-05 13:33:33 EDT
Discovered during indexing the built Mozilla project in Linux.

NPE caused by the file 
/home/dsteffle/mozilla-1_7_5/mozilla/xpcom/ds/nsStringEnumerator.cpp
during a call to CPPMethod#getVisibility() with
CPPASTQualifiedName==nsStringEnumerator::GetNext

java.lang.NullPointerException
	at
org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethod.getVisibility(CPPMethod.java:143)
	at
org.eclipse.cdt.internal.core.index.domsourceindexer.IndexVisitorUtil.getModifiers(IndexVisitorUtil.java:61)
	at
org.eclipse.cdt.internal.core.index.domsourceindexer.CPPGenerateIndexVisitor.processNameBinding(CPPGenerateIndexVisitor.java:296)
	at
org.eclipse.cdt.internal.core.index.domsourceindexer.CPPGenerateIndexVisitor.processName(CPPGenerateIndexVisitor.java:169)
	at
org.eclipse.cdt.internal.core.index.domsourceindexer.CPPGenerateIndexVisitor.visit(CPPGenerateIndexVisitor.java:112)
	at
org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName.accept(CPPASTName.java:90)
	at
org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName.accept(CPPASTQualifiedName.java:175)
	at
org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarator.accept(CPPASTDeclarator.java:126)
	at
org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDefinition.accept(CPPASTFunctionDefinition.java:92)
	at
org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit.accept(CPPASTTranslationUnit.java:520)
	at
org.eclipse.cdt.internal.core.index.domsourceindexer.DOMSourceIndexerRunner.indexFile(DOMSourceIndexerRunner.java:133)
	at
org.eclipse.cdt.internal.core.index.domsourceindexer.AbstractIndexerRunner.index(AbstractIndexerRunner.java:76)
	at org.eclipse.cdt.internal.core.index.cindexstorage.Index.add(Index.java:110)
	at
org.eclipse.cdt.internal.core.index.domsourceindexer.DOMAddCompilationUnitToIndex.indexDocument(DOMAddCompilationUnitToIndex.java:29)
	at
org.eclipse.cdt.internal.core.index.domsourceindexer.DOMAddFileToIndex.execute(DOMAddFileToIndex.java:60)
	at
org.eclipse.cdt.internal.core.search.processing.JobManager.run(JobManager.java:466)
	at java.lang.Thread.run(Thread.java:595)
Comment 1 John Camelon CLA 2005-07-06 20:36:06 EDT
Can this be a candidate for RC2?
Comment 2 Devin Steffler CLA 2005-07-07 10:21:29 EDT
Would it be ok to have CPPMethod#getVisibility() return 
ICPPASTVisibilityLabel.v_private if the declaration for the CPPMethod is null?

The declaration is null because getPrimaryDeclaration() returns null since 
declarations==null and no member in the scope has the same binding as the 
CPPMethod.  Or would it be better to troubleshoot this further since this 
should probably never happen anyways?
Comment 3 John Camelon CLA 2005-07-07 10:27:56 EDT
troubleshoot to find the scenario to see if it is preventable.  
implement your solution (returning private) irregardless of the scenario.
Comment 4 Devin Steffler CLA 2005-07-07 13:27:28 EDT
Created attachment 24430 [details]
fix for this PR

The reason why getPrimaryDeclaration() returns null still needs to be
investigated.
Comment 5 Andrew Niefer CLA 2005-07-07 15:16:40 EDT
done. though, if we can, we check the containing class and return public if its
a struct.