Bug 323641 - StringIndexOutOfBoundsException in AutotoolsScannerInfo.getDefinedSymbols
Summary: StringIndexOutOfBoundsException in AutotoolsScannerInfo.getDefinedSymbols
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: eclipse-cdt
Version: rawhide
Hardware: All
OS: Linux
low
high
Target Milestone: ---
Assignee: Jeff Johnston
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-10-08 19:46 UTC by José Fonseca
Modified: 2007-11-30 22:12 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2007-10-09 19:09:47 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
build.log (37.65 KB, text/plain)
2007-10-08 19:46 UTC, José Fonseca
no flags Details
Patch that fixes the problem (1.92 KB, patch)
2007-10-09 09:33 UTC, José Fonseca
no flags Details | Diff

Description José Fonseca 2007-10-08 19:46:38 UTC
Description of problem:

I get many exceptions like this with the autotools plugin (the index varies):

java.lang.StringIndexOutOfBoundsException: String index out of range: -110
	at java.lang.String.substring(String.java:1938)
	at
com.redhat.eclipse.cdt.autotools.AutotoolsScannerInfo.getDefinedSymbols(AutotoolsScannerInfo.java:321)
	at
org.eclipse.cdt.internal.core.pdom.indexer.PDOMIndexerTask.computeHashCode(PDOMIndexerTask.java:570)
	at
org.eclipse.cdt.internal.core.pdom.indexer.PDOMIndexerTask.parseTU(PDOMIndexerTask.java:323)
	at
org.eclipse.cdt.internal.core.pdom.indexer.PDOMIndexerTask.internalParseTUs(PDOMIndexerTask.java:219)
	at
org.eclipse.cdt.internal.core.pdom.indexer.PDOMIndexerTask.parseTUs(PDOMIndexerTask.java:192)
	at
org.eclipse.cdt.internal.core.pdom.indexer.fast.PDOMFastIndexerTask.run(PDOMFastIndexerTask.java:102)
	at
org.eclipse.cdt.internal.core.pdom.indexer.PDOMUpdateTask.run(PDOMUpdateTask.java:73)
	at org.eclipse.cdt.internal.core.pdom.PDOMIndexerJob.run(PDOMIndexerJob.java:90)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)


Version-Release number of selected component (if applicable):

Autotools 0.9.5 and CDT 4.0.1 and Eclipse 3.4M2.

How reproducible:

It happens with many projects in freedesktop.org, such as the glitz source.

Steps to Reproduce:
See the attached build log for the build commands.
  
Additional notes:

This bug renders the CDT indexer and code navigation features completely useless.

I looked into the faulty line in the current CVS but didn't saw anything obvious.

Comment 1 José Fonseca 2007-10-08 19:46:38 UTC
Created attachment 220071 [details]
build.log

Comment 2 José Fonseca 2007-10-09 00:33:04 UTC
Ok, I ran through the debugger and found out the problem. The shortest test case is:

-DINDENTIFIER -fmessage-length=0

That is, you have an identifier without '=' but you have an '=' after the first
space. That means that endIndex < eqSignIndex causing the 
 
  x.substring(eqSignIndex+1, endIndex)

expression to fail.

The fix should not be too hard, but all that complex logic is prone to bugs and
all those calls to IndexOf won't be much fast either, so IMHO sticking to just
regular expressions on getDefinedSymbols would be the right fix here.

Comment 3 José Fonseca 2007-10-09 09:33:59 UTC
Created attachment 221011 [details]
Patch that fixes the problem

I attached a patch that implements the definition extraction with regular
expressions. The regular expression is a bit ugly due to the double escaping
for Java string literals, however it's much easier to grasp. Please apply.

Comment 4 Jeff Johnston 2007-10-09 19:09:47 UTC
Thanks Jose for catching this and for the patch.  Patch has been applied to F7
and F8 (devel) and will appear in the next releases.


Note You need to log in before you can comment on or make changes to this bug.