Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 326352

Summary: java.lang.StringIndexOutOfBoundsException: String index out of range: -248337596
Product: [Eclipse Project] Platform Reporter: funkazzista
Component: ResourcesAssignee: Szymon Ptaszkiewicz <sptaszkiewicz>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: sptaszkiewicz, Szymon.Brandys
Version: 3.6   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Eclipse stacktrace
none
Possible patch v.0.1 none

Description funkazzista CLA 2010-09-27 16:40:28 EDT
Build Identifier: 20100617-1415 (Helios Release)

After having created a new project and imported the C sources, Eclipse gives the following error: 
An internal error occurred during: "Refreshing workspace". 
when trying to navigate the source tree.

Reproducible: Always

Steps to Reproduce:
Tried to import some existing C/C++ project with a Makefile (e.g. E-UAE tarball and PUAE sources pulled from GIT).
1. Download http://www.rcdrummond.net/uae/e-uae-0.8.29-WIP4/e-uae-0.8.29-WIP4.tar.bz2
2. Decompress it somewhere and create a new project in Eclipse
3. Right click on project -> Import -> Existing code as Makefile project and select root directory of E-UAE sources
4. Eclipse error: An internal error occurred during: "Refreshing workspace". with stacktrace in the Details section above.
Comment 1 funkazzista CLA 2010-09-27 16:41:56 EDT
Created attachment 179686 [details]
Eclipse stacktrace
Comment 2 Markus Schorn CLA 2010-09-28 02:02:47 EDT
The exception is raised by the file-system:
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -258403790
at java.lang.String.checkBounds(String.java:368)
at java.lang.String.<init>(String.java:457)
at org.eclipse.core.internal.filesystem.local.unix.UnixFileNatives.bytesToFileName(UnixFileNatives.java:169)
at org.eclipse.core.internal.filesystem.local.unix.UnixFileNatives.fetchFileInfo(UnixFileNatives.java:83)
at org.eclipse.core.internal.filesystem.local.LocalFileNativesManager.fetchFileInfo(LocalFileNativesManager.java:31)
at org.eclipse.core.internal.filesystem.local.LocalFile.fetchInfo(LocalFile.java:144)
Comment 3 Szymon Ptaszkiewicz CLA 2010-10-01 11:28:15 EDT
Created attachment 180066 [details]
Possible patch v.0.1

Possible solution for the bug.

The exception is thrown from a method that seems to be platform dependent (I can't see such method in Sun/Oracle java.lang.String). For Sun/Oracle implementation of java.lang.String the same exception could be thrown if (length > data.length - start) that means if you try to read more chars than it is available in the array. Tracing back the cause you will see that this could happen if the length returned from readlink(name, target, target.length) is bigger than length of the array target. The readlink method is a native method that wraps equivalent unix method but instead of passing the length of the array to this the method it uses PATH_MAX. This is not good because the value is hardcoded with the value appropriate for the OS where the compiler was run while the size of the array is set as PATH_MAX with the value taken directly from the OS running the code.
Comment 4 Szymon Ptaszkiewicz CLA 2010-10-01 11:49:38 EDT
I made a mistake - there is checkBounds method in Sun/Oracle java implementation but it is not part of API.
Comment 5 Szymon Brandys CLA 2011-03-28 11:02:44 EDT
Moving to 3.8.
Comment 6 Szymon Ptaszkiewicz CLA 2014-03-07 08:45:03 EST
I have never been able to reproduce it. Marking WORKSFORME. Please reopen if you see this again or can provide reproducible steps.