Bug 323641 - StringIndexOutOfBoundsException in AutotoolsScannerInfo.getDefinedSymbols
StringIndexOutOfBoundsException in AutotoolsScannerInfo.getDefinedSymbols
Status: CLOSED NEXTRELEASE
Product: Fedora
Classification: Fedora
Component: eclipse-cdt (Show other bugs)
rawhide
All Linux
low Severity high
: ---
: ---
Assigned To: Jeff Johnston
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2007-10-08 15:46 EDT by José Fonseca
Modified: 2007-11-30 17:12 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-10-09 15:09:47 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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

  None (edit)
Description José Fonseca 2007-10-08 15:46:38 EDT
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 15:46:38 EDT
Created attachment 220071 [details]
build.log
Comment 2 José Fonseca 2007-10-08 20:33:04 EDT
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 05:33:59 EDT
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 15:09:47 EDT
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.