Bug 229951 - StackOverflowError during JavaSearchScope.add for large workspace
Summary: StackOverflowError during JavaSearchScope.add for large workspace
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.4 RC1   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-02 10:02 EDT by Seng Phung Lu CLA
Modified: 2008-05-14 05:34 EDT (History)
6 users (show)

See Also:
frederic_fusier: review+


Attachments
Projects reproducing the problem (2.85 KB, patch)
2008-05-09 10:32 EDT, Jerome Lanneluc CLA
no flags Details | Diff
Projects reproducing the problem (3.82 KB, image/zip)
2008-05-09 11:26 EDT, Jerome Lanneluc CLA
no flags Details
Proposed fix and regression tests (12.86 KB, patch)
2008-05-09 12:49 EDT, Jerome Lanneluc CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Seng Phung Lu CLA 2008-05-02 10:02:31 EDT
Build ID: I20080409-1425

Steps To Reproduce:
We are an adoptor product which builds on top of Eclipse.

I think this is a scalability issue.  When working with a large workspace, StackOverflowError occurs during the first build/validate pass launched by Autobuild.  Various parts of our code call resolveType() or search() on the Java model which causes the following JDT code recursively add objects until it reaches a limit.

java.lang.StackOverflowError
at org.eclipse.jdt.internal.core.ClasspathEntry.combineWith(Unknown Source)
at org.eclipse.jdt.internal.core.search.JavaSearchScope.add(Unknown Source)
at org.eclipse.jdt.internal.core.search.JavaSearchScope.add(Unknown Source)
at org.eclipse.jdt.internal.core.search.JavaSearchScope.add(Unknown Source)
...<note: 2000+ lines of the same here>
at org.eclipse.jdt.internal.core.search.JavaSearchScope.add(Unknown Source)
at org.eclipse.jdt.internal.core.search.JavaSearchScope.add(Unknown Source)
at org.eclipse.jdt.internal.core.search.BasicSearchEngine.createJavaSearchScope(Unknown Source)
at org.eclipse.jdt.internal.core.search.BasicSearchEngine.createJavaSearchScope(Unknown Source)
at org.eclipse.jdt.internal.core.search.BasicSearchEngine.createJavaSearchScope(Unknown Source)
at org.eclipse.jdt.internal.core.SearchableEnvironment.<init>(Unknown Source)
at org.eclipse.jdt.internal.core.SearchableEnvironment.<init>(Unknown Source)
at org.eclipse.jdt.internal.core.JavaProject.newSearchableNameEnvironment(Unknown Source)
at org.eclipse.jdt.internal.core.NamedMember.resolveType(Unknown Source)
at org.eclipse.jdt.internal.core.NamedMember.resolveType(Unknown Source)


More information:
Please contact me directly for more information on how to reproduce.
Comment 1 Jerome Lanneluc CLA 2008-05-02 11:47:13 EDT
Have you tried playing with the Java thread stack size? e.g. starting Eclipse with -Xss256k or greater?
Comment 2 Andrew Mak CLA 2008-05-02 12:53:05 EDT
I tried with -Xss2048k and still got the StackOverflowError
Comment 3 Jerome Lanneluc CLA 2008-05-09 10:32:18 EDT
Created attachment 99464 [details]
Projects reproducing the problem

To reproduce:
1. Start a new workspace
2. Change Window>Preferences>Java>Compiler>Building>Build path problems>Circular dependencies to Warning
3. Import the attached projects in the workspace
4. Select P3
5. Search>Java
6. Select Enclosing projects
7. Press Search
Observe: You get a dialog with a stack overflow error
Comment 4 Jerome Lanneluc CLA 2008-05-09 11:26:52 EDT
Created attachment 99483 [details]
Projects reproducing the problem

Actually, the steps reproducing the original problems are slightly different:

To reproduce:
1. Start a new workspace
2. Import the attached projects in the workspace
3. Search>Java
4. Search string: X
5. Check Type
6. Check Declarations
7. Check Workspace
8. Press Search
Observe: You get a dialog with a stack overflow error
Comment 5 Jerome Lanneluc CLA 2008-05-09 12:49:03 EDT
Created attachment 99507 [details]
Proposed fix and regression tests
Comment 6 Jerome Lanneluc CLA 2008-05-09 12:50:20 EDT
Frederic, if you have time can you please review? Otherwise I'll ask someone else :-)
Comment 7 Frederic Fusier CLA 2008-05-11 13:11:11 EDT
Patch looks good: +1
Comment 8 Philipe Mulet CLA 2008-05-12 05:35:00 EDT
Would we have same bug in 3.3.x ?
Comment 9 Jerome Lanneluc CLA 2008-05-12 05:51:51 EDT
(In reply to comment #8)
> Would we have same bug in 3.3.x ?
No. The bug was introduced by the fix to bug 176831, which was not backported to 3.3.x.
Comment 10 Jerome Lanneluc CLA 2008-05-12 06:11:22 EDT
Fix and tests released for 3.4RC1
Comment 11 David Audel CLA 2008-05-14 05:34:25 EDT
Verified for 3.4RC1 using I20080513-2000