Bug 97440 - [1.5][compiler] StackOverflow compiling heavily generic code
Summary: [1.5][compiler] StackOverflow compiling heavily generic code
Status: CLOSED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows 2000
: P3 major (vote)
Target Milestone: 3.1 RC2   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-31 08:21 EDT by Osvaldo Pinali Doederlein CLA
Modified: 2005-06-10 11:59 EDT (History)
1 user (show)

See Also:


Attachments
Test workspace (95.24 KB, application/octet-stream)
2005-05-31 11:42 EDT, Osvaldo Pinali Doederlein CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Osvaldo Pinali Doederlein CLA 2005-05-31 08:21:00 EDT
I'm having this exception, with 3.1RC1:

!ENTRY org.eclipse.core.runtime 4 2 2005-05-31 08:54:30.119
!MESSAGE An internal error occurred during: "Building workspace".
!STACK 0
java.lang.StackOverflowError
	at
org.eclipse.jdt.internal.compiler.lookup.TypeBinding.isEquivalentTo(TypeBinding.java:177)
	at
org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.isCompatibleWith(ReferenceBinding.java:675)
	at
org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.isCompatibleWith(ReferenceBinding.java:687)
	at
org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.isCompatibleWith(ReferenceBinding.java:687)
...

The project being compiled makes heavy use of generic types, including type
bounds, wildcards etc. and looking at ReferenceBinding.isCompatibleWith() the
problem seems to be related to generic types.  Unfortunately the error logs
don't include any information about the source elements that caused the problem
(not even source file).

After (and only if) this error happens, if I try to exit Eclipse or wait until
the next periodic workspace save, another error happens, but I guess this
second error is a side effect of the former:

!ENTRY org.eclipse.ui.ide 4 1 2005-05-31 08:54:36.463
!MESSAGE Problems occurred while trying to save the state of the workbench.
!SUBENTRY 1 org.eclipse.core.resources 4 568 2005-05-31 08:54:36.463
!MESSAGE Could not write metadata for: /PSS_30.
!STACK 0
java.io.UTFDataFormatException: encoded string too long: 109612 bytes
	at java.io.DataOutputStream.writeUTF(DataOutputStream.java:347)
	at java.io.DataOutputStream.writeUTF(DataOutputStream.java:306)
	at org.eclipse.core.internal.resources.MarkerWriter.write(MarkerWriter.java:181)
...

Problem didn't happen with M7/RC0, and doesn't happen with many other projects
that I have, including others that use lots of generic types too.
Comment 1 Philipe Mulet CLA 2005-05-31 10:11:43 EDT
Please provide steps to reproduce, then reopen.
Normally, an additional problem should have been added on line 1 of offending
file; associated to a message containing the stack trace you got in the log.

This should help you narrow the problem.
Comment 2 Osvaldo Pinali Doederlein CLA 2005-05-31 11:42:16 EDT
Created attachment 22056 [details]
Test workspace
Comment 3 Osvaldo Pinali Doederlein CLA 2005-05-31 11:47:26 EDT
Oops, your're right, the compiler creates a problem marker pointing to the
source file that caused the error.  So I managed to produce a minimal workspace
(attached) that shows the problem.  Steps to reproduce:

1) Fresh install of Eclipse RC1 (just Platform + JDT)
2) Open this workspace
3) CTRL+B to build --> produces the compiler error
4) Open the file PSClass.java --> produces another related error,
   "Requesting Java AST from selection".  Then you have to close the
   editor, otherwise  this error cycles in a loop if you close the dialog.
Comment 4 John Arthorne CLA 2005-05-31 13:21:31 EDT
The second stack trace indicates that an IMarker had a message of more than
65,536 bytes in length. Perhaps the stack trace of the StackOverflowError is
being added to the marker message or another marker property, causing a very
long message?
Comment 5 John Arthorne CLA 2005-05-31 13:38:45 EDT
I have entered bug 97608 against platform resources to handle the marker save
failure (second stack).
Comment 6 Frederic Fusier CLA 2005-06-08 12:43:51 EDT
Reproduced using build N20050608-0010 on workspace provided in comment 2.
You just need ot open PSClass.java and click everywhere in the code or move the
cursor...
Comment 7 Philipe Mulet CLA 2005-06-09 07:16:05 EDT
Simpler testcase:

public class X<E> {
	X<? super E> parent;
	X<? super E> current;
	void foo() {
		current = current.parent;
	}
}
Comment 8 Philipe Mulet CLA 2005-06-09 07:45:05 EDT
Our protection for circular captures didn't perform for lower bounds.
Fixed, added GenericTypeTest#test
Comment 9 Frederic Fusier CLA 2005-06-09 08:26:17 EDT
Verified for 3.1 RC2 using build N20050609-0010 + JDT/Core HEAD
Comment 10 Jerome Lanneluc CLA 2005-06-10 11:59:58 EDT
Verified with I20050610-0010