Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 243691 - [templates] StackOverflowError on Content Assist
Summary: [templates] StackOverflowError on Content Assist
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.4   Edit
Hardware: All All
: P3 normal with 1 vote (vote)
Target Milestone: 3.5 M2   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 240259 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-08-10 15:27 EDT by Steven Tamm CLA
Modified: 2008-09-18 12:01 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Tamm CLA 2008-08-10 15:27:27 EDT
The first time I do a "Content Assist" in a workspace after startup (With Other Java, Template, and Type specified), I get this StackOverflowException.  After ignoring the error, subsequent content assists work fine.  I can't get to the start of the stack trace, unfortunately, but I can reproduce this at will in our very large project.  Eclipse is running with -Xss256k.

!SESSION 2008-08-10 12:17:43.859 -----------------------------------------------
eclipse.buildId=I20080617-2000
java.version=1.5.0_15
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Command-line arguments:  -os linux -ws gtk -arch x86_64

!ENTRY org.eclipse.ui 2 0 2008-08-10 12:17:47.595
!MESSAGE Warnings while parsing the key bindings from the 'org.eclipse.ui.commands' extension point
!SUBENTRY 1 org.eclipse.ui 2 0 2008-08-10 12:17:47.595

!ENTRY org.eclipse.ui 4 0 2008-08-10 12:18:14.384
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.StackOverflowError
	at java.util.regex.Pattern$Loop.match(Pattern.java:4685)
	at java.util.regex.Pattern$GroupTail.match(Pattern.java:4637)
	at java.util.regex.Pattern$GroupTail.match(Pattern.java:4637)
	at java.util.regex.Pattern$BitClass.match(Pattern.java:2876)
	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4578)
	at java.util.regex.Pattern$Branch.match(Pattern.java:4538)
	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4578)
	at java.util.regex.Pattern$Loop.match(Pattern.java:4705)
	at java.util.regex.Pattern$GroupTail.match(Pattern.java:4637)
	at java.util.regex.Pattern$GroupTail.match(Pattern.java:4637)
	at java.util.regex.Pattern$BitClass.match(Pattern.java:2876)
	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4578)
	at java.util.regex.Pattern$Branch.match(Pattern.java:4538)
	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4578)
	at java.util.regex.Pattern$Loop.match(Pattern.java:4705)
	at java.util.regex.Pattern$GroupTail.match(Pattern.java:4637)
	at java.util.regex.Pattern$GroupTail.match(Pattern.java:4637)
	at java.util.regex.Pattern$BitClass.match(Pattern.java:2876)
	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4578)
	at java.util.regex.Pattern$Branch.match(Pattern.java:4538)
	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4578)
	at java.util.regex.Pattern$Loop.match(Pattern.java:4705)
	at java.util.regex.Pattern$GroupTail.match(Pattern.java:4637)
	at java.util.regex.Pattern$GroupTail.match(Pattern.java:4637)
	at java.util.regex.Pattern$BitClass.match(Pattern.java:2876)
	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4578)
	at java.util.regex.Pattern$Branch.match(Pattern.java:4538)
	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4578)
	at java.util.regex.Pattern$Loop.match(Pattern.java:4705)
	at java.util.regex.Pattern$GroupTail.match(Pattern.java:46370
... (about 1000 lines)
	at java.util.regex.Pattern$BitClass.match(Pattern.java:2876)
	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4578)
	at java.util.regex.Pattern$Branch.match(Pattern.java:4538)
	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4578)
Comment 1 Olivier Thomann CLA 2008-08-12 09:55:57 EDT
Steps to reproduce are required for further investigation.
Comment 2 Steven Tamm CLA 2008-08-12 11:16:23 EDT
Meh.  My eclipse.ini unfortunately turned down the stack size to -Xss256k.  When I set it back to 512k, it was fine.  

However, I didn't hit it anywhere else in eclipse after a month.  The java implementation of regex often goes off the stack deepend, but feel free to punt.

1. It only applies if "Template" proposal is enabled in content assist.

2.  Here's the base of the stacktrace where it dies, I couldn't find the template that was failing however. 

	Pattern$Branch.match(Matcher, int, CharSequence) line: 4538	
	Pattern$Branch.match(Matcher, int, CharSequence) line: 4538	
	Pattern$Start.match(Matcher, int, CharSequence) line: 3019	
	Matcher.search(int) line: 1092	
	Matcher.find() line: 528	
	TemplateTranslator.parse(String) line: 167	
	TemplateTranslator.translate(String) line: 149	
	JavaContextType(TemplateContextType).validate(String) line: 200	
	ContributionTemplateStore.validateTemplate(Template) line: 194	
	ContributionTemplateStore.readIncludedTemplates(Collection, IConfigurationElement) line: 156	
	ContributionTemplateStore.readContributedTemplates(IConfigurationElement[]) line: 120	
	ContributionTemplateStore.loadContributedTemplates() line: 107	
	ContributionTemplateStore(TemplateStore).load() line: 108	
	JavaPlugin.getTemplateStore() line: 849	
	TemplateEngine.complete(ITextViewer, int, ICompilationUnit) line: 124	
	TemplateCompletionProposalComputer(AbstractTemplateCompletionProposalComputer).computeCompletionProposals(ContentAssistInvocationContext, IProgressMonitor) line: 63	
	CompletionProposalComputerDescriptor.computeCompletionProposals(ContentAssistInvocationContext, IProgressMonitor) line: 316	
	CompletionProposalCategory.computeCompletionProposals(ContentAssistInvocationContext, String, SubProgressMonitor) line: 264	
	JavaCompletionProcessor(ContentAssistProcessor).collectProposals(ITextViewer, int, IProgressMonitor, ContentAssistInvocationContext) line: 285	
	JavaCompletionProcessor(ContentAssistProcessor).computeCompletionProposals(ITextViewer, int) line: 245	
	ContentAssistant.computeCompletionProposals(ITextViewer, int) line: 1836	
	CompletionProposalPopup.computeProposals(int) line: 553	
	CompletionProposalPopup.access$16(CompletionProposalPopup, int) line: 550	
	CompletionProposalPopup$2.run() line: 485	
	BusyIndicator.showWhile(Display, Runnable) line: 70	
	CompletionProposalPopup.showProposals(boolean) line: 479	
	ContentAssistant.showPossibleCompletions() line: 1664	
	CompilationUnitEditor$AdaptedSourceViewer.doOperation(int) line: 177	
	ContentAssistAction$1.run() line: 82	
	BusyIndicator.showWhile(Display, Runnable) line: 70	
	ContentAssistAction.run() line: 80	
	ContentAssistAction(Action).runWithEvent(Event) line: 498	
	ActionHandler.execute(Map) line: 185	
	LegacyHandlerWrapper.execute(ExecutionEvent) line: 109	
	Command.executeWithChecks(ExecutionEvent) line: 476	
	ParameterizedCommand.executeWithChecks(Object, Object) line: 508	
	HandlerService.executeCommand(ParameterizedCommand, Event) line: 169	
...
Comment 3 David Audel CLA 2008-09-03 09:18:15 EDT
Template proposals are computed by JDTText.
Comment 4 Dani Megert CLA 2008-09-03 10:09:19 EDT
That's not our bug, see:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5050507

A test case would help. Maybe we can do something to avoid the exception. Please reopen if you have steps to reproduce this problem.
Comment 5 Markus Keller CLA 2008-09-03 19:06:52 EDT
See also bug 240259. With -Xss128K, I ran into a StackOverflowError while parsing the "org.eclipse.jdt.ui.text.codetemplates.swt.datetime" template.

The stack for matching the TemplateTranslator.ESCAPE_PATTERN was really a bit high.

Fixed in HEAD of TemplateTranslator by adding a few possessives to the regexes to avoid backtracking (e.g. '*+' instead of '*').
Comment 6 Markus Keller CLA 2008-09-03 19:11:31 EDT
*** Bug 240259 has been marked as a duplicate of this bug. ***
Comment 7 Dani Megert CLA 2008-09-18 12:01:26 EDT
Verified in I20080918-0100.