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

Bug 358555

Summary: StackOverflowError in DocumentUtil
Product: [Modeling] TMF Reporter: Moritz Eysholdt <moritz.eysholdt>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: b.kolb, sebastian.zarnekow
Version: 2.0.1Flags: sebastian.zarnekow: indigo+
Target Milestone: SR2   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Moritz Eysholdt CLA 2011-09-22 06:05:17 EDT
In a DSL-document when I press enter within a comment, I got the exception stated below. 

The recursion in DocumentUtil.findNextOffSetInPartition is never cancelled because partition2.getLength() == 0;

This occurred in Xtext 2.0.1.v201108310706

Type pof partition2 is "__dftl_partition_content_type", type of partition is "__comment".

java.lang.StackOverflowError
	at org.eclipse.jface.text.AbstractDocument.computeIndexInPositionList(AbstractDocument.java:455)
	at org.eclipse.jface.text.AbstractDocument.computeIndexInCategory(AbstractDocument.java:544)
	at org.eclipse.jface.text.rules.FastPartitioner.getPartition(FastPartitioner.java:484)
	at org.eclipse.jface.text.rules.FastPartitioner.getPartition(FastPartitioner.java:592)
	at org.eclipse.jface.text.AbstractDocument.getPartition(AbstractDocument.java:1495)
	at org.eclipse.jface.text.AbstractDocument.getPartition(AbstractDocument.java:966)
	at org.eclipse.xtext.ui.editor.model.DocumentUtil.findNextOffSetInPartition(DocumentUtil.java:86)
	at org.eclipse.xtext.ui.editor.model.DocumentUtil.findNextOffSetInPartition(DocumentUtil.java:91)
	at org.eclipse.xtext.ui.editor.model.DocumentUtil.findNextOffSetInPartition(DocumentUtil.java:91)
	at org.eclipse.xtext.ui.editor.model.DocumentUtil.findNextOffSetInPartition(DocumentUtil.java:91)
	at org.eclipse.xtext.ui.editor.model.DocumentUtil.findNextOffSetInPartition(DocumentUtil.java:91)
	at org.eclipse.xtext.ui.editor.model.DocumentUtil.findNextOffSetInPartition(DocumentUtil.java:91)
	at org.eclipse.xtext.ui.editor.model.DocumentUtil.findNextOffSetInPartition(DocumentUtil.java:91)
	at org.eclipse.xtext.ui.editor.model.DocumentUtil.findNextOffSetInPartition(DocumentUtil.java:91)
	at org.eclipse.xtext.ui.editor.model.DocumentUtil.findNextOffSetInPartition(DocumentUtil.java:91)
	at org.eclipse.xtext.ui.editor.model.DocumentUtil.findNextOffSetInPartition(DocumentUtil.java:91)
	at org.eclipse.xtext.ui.editor.model.DocumentUtil.findNextOffSetInPartition(DocumentUtil.java:91)
	at org.eclipse.xtext.ui.editor.model.DocumentUtil.findNextOffSetInPartition(DocumentUtil.java:91)
Comment 1 Sebastian Zarnekow CLA 2011-09-22 06:50:19 EDT
Hi Moritz,

please provide an input model + cursor position that reproduces the issue.
Comment 2 Moritz Eysholdt CLA 2011-09-29 08:56:23 EDT
*** Bug 357203 has been marked as a duplicate of this bug. ***
Comment 3 Sebastian Zarnekow CLA 2011-10-24 17:39:24 EDT
I tried various combinations of comments that immediatly followed each other, were at the beginning of the file or at the end. Could you please provide a reproducable example?
Comment 4 Moritz Eysholdt CLA 2011-10-24 18:50:24 EDT
It took me a while to "reverse engineer" this bug's required state... but I found it:

1. create an .xtend file
----
class bar { 

/* ! /**/ 
		
}
----

2. Locate the cursor behind the exclamation mark
3. Press enter
4. Watch the stack flow over.
Comment 5 Sebastian Zarnekow CLA 2011-10-24 18:52:36 EDT
(In reply to comment #4)
> It took me a while to "reverse engineer" this bug's required state... but I
> found it

Great! Do you have the time to look into this?
Comment 6 Moritz Eysholdt CLA 2011-10-25 04:31:23 EDT
fixed. pushed to master.

please review: http://git.eclipse.org/c/tmf/org.eclipse.xtext.git/commit/?id=33c8f6f69bb7c2db672635051177a766c24684f7
Comment 7 Moritz Eysholdt CLA 2011-10-25 05:22:29 EDT
added test case: org.eclipse.xtext.ui.junit.editor.autoedit.AbstractCStyleLanguageAutoEditTest.testBug358555()
Comment 8 Karsten Thoms CLA 2017-09-19 17:48:16 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 9 Karsten Thoms CLA 2017-09-19 17:59:23 EDT
Closing all bugs that were set to RESOLVED before Neon.0