Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 245851 - Schema causes stack error
Summary: Schema causes stack error
Status: CLOSED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xml (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows Vista
: P2 major (vote)
Target Milestone: 3.0.3   Edit
Assignee: Keith Chong CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-01 06:11 EDT by Laurens Holst CLA
Modified: 2008-12-17 13:46 EST (History)
5 users (show)

See Also:
thatnitind: review+
nsand.dev: review? (keith.chong.ca)
for.work.things: review+


Attachments
Testcase (50.49 KB, application/x-zip-compressed)
2008-09-01 06:11 EDT, Laurens Holst CLA
no flags Details
patch to prevent stack overflow (1.38 KB, patch)
2008-09-03 17:03 EDT, Nick Sandonato CLA
no flags Details | Diff
Updated patch (6.51 KB, patch)
2008-09-08 14:10 EDT, Keith Chong CLA
no flags Details | Diff
Updated patch (6.20 KB, patch)
2008-09-15 14:17 EDT, Keith Chong CLA
no flags Details | Diff
Apply to org.eclipse.wst.xsd.core.tests (7.06 KB, patch)
2008-09-15 14:19 EDT, Keith Chong CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Laurens Holst CLA 2008-09-01 06:11:41 EDT
Created attachment 111400 [details]
Testcase

Build ID: I20080617-2000

Hi,

Again found a regression with the Schema validation, causing a stack error. Probably related to bug 238550?

Of the attached test case, open test.xml in the editor, and click somewhere in the table’s body. You will receive the following error:

  Unhandled event loop exception
  java.lang.StackOverflowError

Also once I received the following error (but have not been able to find steps to reproduce it):

  Refreshing outline has encountered an error: Error

~Grauw
Comment 1 Nick Sandonato CLA 2008-09-03 17:03:24 EDT
Created attachment 111632 [details]
patch to prevent stack overflow

This patch adds a stack to XSDVistor#visitParticle to prevent stack overflows caused by recursive schema definitions. An example of this from the provided XSDs is:

<xs:group name="xhtml.table.content">
			<xs:sequence>
				<xs:choice>
					<xs:group ref="xhtml.table.content"/>
					<xs:any namespace="##other" processContents="lax"/>
				</xs:choice>
			</xs:sequence>
		</xs:group>
Comment 2 Nitin Dahyabhai CLA 2008-09-03 23:43:25 EDT
After talking with Keith briefly, I'm assigning this to him for further investigation.
Comment 3 Laurens Holst CLA 2008-09-04 04:02:49 EDT
Is it really recursive? The example given is part of a redefinition, so the xs:group inside the group actually refers to another xs:group defined in xhtml11-modules-1.xsd...
Comment 4 Keith Chong CLA 2008-09-08 14:10:32 EDT
Created attachment 111985 [details]
Updated patch
Comment 5 Keith Chong CLA 2008-09-08 15:27:00 EDT
Added updated patch.  Plugins changed: org.eclipse.wst.xsd.core and org.eclipse.wst.xml.core.

This patch should also fix content assist, (Ctrl-space in the Source view, or bring up context menu in the Design view), which also resulted in a stack overflow.  

Laurens, can you please apply the patch and verify it fixes your problem?  It's a redefine of the group, however, the XSD model resolves the group to be the one associated with the redefine element, which results in the circular behaviour. (isCircular returns true).

Note that the XSD model has many problems with XSD redefines.  Generally, their use should be avoided.  See

https://bugs.eclipse.org/bugs/show_bug.cgi?id=83055

and associated bugs that are dup'ed to this.
Comment 6 Laurens Holst CLA 2008-09-09 04:19:37 EDT
(In reply to comment #5)
> Laurens, can you please apply the patch and verify it fixes your problem?

I don’t have the source code or a compilation environment for the source code set up. If you can point me to a nightly build though I would be happy to try it out.

> Note that the XSD model has many problems with XSD redefines.  Generally, their
> use should be avoided.

I’m just using the XHTML Modularisation standard’s schemas in the way they are intended to be used (well, somewhat)... :)

~Grauw
Comment 7 David Williams CLA 2008-09-15 01:40:46 EDT
I'm reading bugs closely now that there's only 2 days left, and couldn't see how this was a "cricital" problem: "crashes, loss of data, severe memory leak". 

It does sound like a major problem for sure, and I'd like to get the patches applied as soon as 3.0.2 is released (like, in one week). 

Let me know if I am mis-ready the bug somehow and it does result in crashes or data loss. 

Comment 8 Keith Chong CLA 2008-09-15 14:17:36 EDT
Created attachment 112573 [details]
Updated patch

Updated patch to push stack check up to the base classes CMVisitor and XSDVisitor.
Comment 9 Keith Chong CLA 2008-09-15 14:19:03 EDT
Created attachment 112574 [details]
Apply to org.eclipse.wst.xsd.core.tests

Added some JUnit tests
Comment 10 Amy Wu CLA 2008-10-01 23:02:52 EDT
fix looked good to me.
Comment 11 Keith Chong CLA 2008-10-02 17:20:13 EDT
Fix released to 3.0.3. (M-3.0.3-20081002060554)
Comment 12 Laurens Holst CLA 2008-12-10 08:22:14 EST
Verified fixed in the 3.0.3 release.
Comment 13 Valentin Baciu CLA 2008-12-17 13:46:56 EST
Closing.