Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 361963 - Stack overflow when trying to code complete a generic list
Summary: Stack overflow when trying to code complete a generic list
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.8   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.7.2   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 378007 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-10-25 13:06 EDT by Remy Suen CLA
Modified: 2012-04-28 15:16 EDT (History)
8 users (show)

See Also:
daniel_megert: pmc_approved+


Attachments
Workspace log (728.22 KB, text/plain)
2011-10-25 13:06 EDT, Remy Suen CLA
no flags Details
Workspace with a test project (zip file) (5.63 MB, application/octet-stream)
2011-10-25 14:29 EDT, Remy Suen CLA
no flags Details
A simple code snippet that can easily be used to reproduce the error (355 bytes, text/plain)
2011-12-09 00:52 EST, Leo Bayer CLA
no flags Details
Patch under test (3.40 KB, text/plain)
2012-01-12 04:59 EST, Srikanth Sankaran CLA
daniel_megert: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Remy Suen CLA 2011-10-25 13:06:03 EDT
Created attachment 205936 [details]
Workspace log

I20111018-0850

I had something like this...

List<SomeTypeName> x = new ArrayList<STN>();

...and I tried to invoke code completion between the 'N' and the '>' in the array list instantiation part. After a bit of processing, Eclipse told me that it had gotten a stack overflow.

java.lang.StackOverflowError
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.convertToParameterizedType(LookupEnvironment.java:446)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.convertToParameterizedType(LookupEnvironment.java:453)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.convertToParameterizedType(LookupEnvironment.java:453)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.convertToParameterizedType(LookupEnvironment.java:453)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.convertToParameterizedType(LookupEnvironment.java:453)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.convertToParameterizedType(LookupEnvironment.java:453)
Comment 1 Ayushman Jain CLA 2011-10-25 14:08:51 EDT
I couldn't reproduce on an independent test case. Is it possible to share the exact compilation unit where it happened?
Comment 2 Remy Suen CLA 2011-10-25 14:29:54 EDT
Created attachment 205949 [details]
Workspace with a test project (zip file)

Please try to reproduce with I20111018-0850 or above.
Comment 3 Remy Suen CLA 2011-10-25 14:36:26 EDT
I use p2 to update to I20111018-0850. When it was first unzipped the build was I20110927-0800. I cannot reproduce the problem with a newly unzipped I20111025-1043 (4.x).
Comment 4 elhanan Maayan CLA 2011-12-06 14:44:57 EST
i can confirm this also happens on indigo 3.7 sr 2

eclipse.buildId=M20110909-1335
java.version=1.6.0_27
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=iw_IL
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product

Error
Tue Dec 06 21:36:28 IST 2011
Unhandled event loop exception

java.lang.StackOverflowError
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.convertToParameterizedType(LookupEnvironment.java:453)
Comment 5 Remy Suen CLA 2011-12-06 14:48:08 EST
(In reply to comment #4)
> i can confirm this also happens on indigo 3.7 sr 2
> 
> eclipse.buildId=M20110909-1335

Note that SR2 has not been released yet. You are using SR1.
Comment 6 Leo Bayer CLA 2011-12-09 00:52:53 EST
Created attachment 208135 [details]
A simple code snippet that can easily be used to reproduce the error

Hopefully this is helpful...

I ran into this problem today when I was trying to do completion on some code that really shouldn't be possible to complete.  I've attached a code snippet that does it.

If you trigger completion after the comma in the construction of the new HashMap the stack overflow occurs.
Comment 7 Ayushman Jain CLA 2011-12-09 01:25:57 EST
(In reply to comment #6)
> Created attachment 208135 [details]
> A simple code snippet that can easily be used to reproduce the error

Thanks a lot Leo. I can reproduce consistently with this snippet.
Happens due to recursive call of LookupEnvironment#convertToParameterizedType(..)
This is a regression in 3.7 over 3.6.2. Possible candidate for 3.7.2
Comment 8 Srikanth Sankaran CLA 2011-12-09 20:06:40 EST
(In reply to comment #7)

> This is a regression in 3.7 over 3.6.2. Possible candidate for 3.7.2

Agreed, but will reset target to 3.8 M5 so this stays in the radar for
M5 planning. After fix becomes available, we can evaluate back port
options.
Comment 9 Troy CLA 2011-12-20 19:40:57 EST
I've seen the problem too.

eclipse.buildId=M20110909-1335
java.version=1.6.0_26
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_NZ
Framework arguments:  -showlocation -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -showlocation -product org.eclipse.epp.package.jee.product
Comment 10 Ayushman Jain CLA 2011-12-21 00:04:59 EST
(In reply to comment #9)
> I've seen the problem too.
Let us know if you have a test case that you can put here. Although we already have test cases submitted above, the more the better. :)
Comment 11 Srikanth Sankaran CLA 2012-01-12 01:33:08 EST
(In reply to comment #6)
> Created attachment 208135 [details]
> A simple code snippet that can easily be used to reproduce the error
> 
> Hopefully this is helpful...

Thanks, Even shorter example:

public class X {
	void g() {
        return new X() {
            void g() {
                Object o = new HashMap<|
Comment 12 Srikanth Sankaran CLA 2012-01-12 03:15:21 EST
(In reply to comment #11)

[...]

>         return new X() {
>             void g() {
>                 Object o = new HashMap<|

We are confusing the inner allocation expression to be
a qualified allocation expression of the form

    new X().new HashMap

Patch will follow shortly.
Comment 13 Srikanth Sankaran CLA 2012-01-12 04:59:30 EST
Created attachment 209358 [details]
Patch under test

This patches fixes the problem and also passes RunAllCompletionTests.
Running all tests now.
Comment 15 Ayushman Jain CLA 2012-01-12 07:32:02 EST
(In reply to comment #13)
> Created attachment 209358 [details]
> Patch under test

The patch looks good. Since this is a regression, should we consider for 3.7.2?
Comment 16 Srikanth Sankaran CLA 2012-01-12 07:43:39 EST
(In reply to comment #15)

> The patch looks good. Since this is a regression, should we consider for 3.7.2?

(In reply to comment #7)

> This is a regression in 3.7 over 3.6.2. Possible candidate for 3.7.2

Dani, four different individuals have run into this bug and have
commented on this entry. It is a single line fix and I would say
a safe fix. Patch has been reviewed by Ayush. We would like this
for 3.7.2.
Comment 17 Dani Megert CLA 2012-01-12 11:21:42 EST
(In reply to comment #16)
> (In reply to comment #15)
> 
> > The patch looks good. Since this is a regression, should we consider for 3.7.2?
> 
> (In reply to comment #7)
> 
> > This is a regression in 3.7 over 3.6.2. Possible candidate for 3.7.2
> 
> Dani, four different individuals have run into this bug and have
> commented on this entry. It is a single line fix and I would say
> a safe fix. Patch has been reviewed by Ayush. We would like this
> for 3.7.2.

+1 for 3.7.2.
Comment 18 Ayushman Jain CLA 2012-01-12 11:31:53 EST
Reopening for backport.
Comment 19 Ayushman Jain CLA 2012-01-18 01:17:49 EST
Released into 3.7 maintenance via commit 41e56888a23cc57b7575089de55ab6cc49d9a85d
Comment 20 Satyam Kandula CLA 2012-01-19 05:50:49 EST
Verified for 3.7.2RC2 using build M20120118-0800
Comment 21 Jay Arthanareeswaran CLA 2012-03-12 02:04:39 EDT
This seem to have been missed out in our M5 verification. Marking it for M6.
Comment 22 Jay Arthanareeswaran CLA 2012-03-13 01:48:39 EDT
Verified for 3.8 M6 using build I20120312-1800
Comment 23 Markus Keller CLA 2012-04-28 15:16:06 EDT
*** Bug 378007 has been marked as a duplicate of this bug. ***