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

Bug 238550

Summary: Schema code completion causes stack error
Product: [WebTools] WTP Source Editing Reporter: Laurens Holst <laurens.nospam>
Component: wst.xmlAssignee: Keith Chong <keith.chong.ca>
Status: CLOSED FIXED QA Contact: Nitin Dahyabhai <thatnitind>
Severity: critical    
Priority: P2 CC: d_a_carver, hjzhang, valentinbaciu
Version: 3.0Flags: valentinbaciu: pmc_approved? (david_williams)
valentinbaciu: pmc_approved? (raghunathan.srinivasan)
valentinbaciu: pmc_approved? (naci.dai)
deboer: pmc_approved+
valentinbaciu: pmc_approved? (neil.hauge)
valentinbaciu: pmc_approved? (kaloyan)
valentinbaciu: review+
thatnitind: review+
Target Milestone: 3.0.1   
Hardware: PC   
OS: Windows Vista   
Whiteboard: PMC_approved
Attachments:
Description Flags
Testcase
none
Stack trace zip
none
Apply to org.eclipse.wst.xml.core none

Description Laurens Holst CLA 2008-06-26 06:43:18 EDT
Build ID: I20080617-2000

We at Backbase (www.backbase.com) are shipping a modified XHTML 1.1 (Modularization) schema to our customers to facilitate code-completion of XHTML.

Unfortunately, in Eclipse 3.4, this schema now causes a stack error, prompting the user to restart Eclipse. This is a regression. The error is as follows:

  Unhandled event loop exception
  java.lang.StackOverflowError

I will attach a testcase. I hope you can resolve this, because for us this is a major issue.

Steps To Reproduce:
1. Open schema-test.xml in the attached archive in Eclipse
2. Anywhere in that document, type <
3. Press ctrl-space to initiate the code completion
4. Get stack error


Regards,

Laurens Holst
Developer, Backbase

(By the way, why are .html files always locked to the HTML editor, even when I set the XML editor as default? Now we can not use our customized HTML schema in Eclipse for .html files. But that’s a separate issue.)
Comment 1 Valentin Baciu CLA 2008-06-26 10:12:18 EDT
Please don't forget to attach the schema and/or test case.
Comment 2 Laurens Holst CLA 2008-06-26 10:15:28 EDT
Created attachment 105911 [details]
Testcase

Ah, sorry, thank you :). Testcase attached.

Opening the schema-test.xml file and trying to use code completion should exhibit the issue.
Comment 3 Valentin Baciu CLA 2008-06-26 10:28:05 EDT
Created attachment 105915 [details]
Stack trace zip

Stack overflow trace.
Comment 4 Valentin Baciu CLA 2008-06-26 11:54:44 EDT
The stack trace seems to indicate that CMDescriptionBuilder cannot handle this schema. This code hasn't changed recently, so perhaps there's a new (recursive?) pattern in this modified schema that this code doesn't handle properly.



Comment 5 Laurens Holst CLA 2008-06-26 13:08:07 EDT
I have not changed anything in the last two months. I just re-tested it in Eclipse 3.3 (confirming that it is not an issue there, so it really is a regression).
Comment 6 Valentin Baciu CLA 2008-06-26 13:32:52 EDT
OK, we'll then look deeper in the content model XSD adapter code to see if anything's changed there.
Comment 7 Keith Chong CLA 2008-07-30 16:49:35 EDT
The CMDescriptionBuilder should take account of cyclic model group references, The groups are visited over and over again, which leads to the stackoverflow.


Comment 8 Keith Chong CLA 2008-07-30 16:51:13 EDT
Created attachment 108782 [details]
Apply to org.eclipse.wst.xml.core
Comment 9 Keith Chong CLA 2008-07-30 17:34:22 EDT
1. Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug" (requested by an adopter) please document it as such.

User has to shut down the workbench.

2. Is there a work-around? If so, why do you believe the work-around is insufficient?

None

3. How has the fix been tested? Is there a test case attached to the bugzilla record? Has a JUnit Test been added?

Tested manually and it does fix the problem scenario.  See bug 242639.  Will investigate adding the JUnit later.

4. Give a brief technical overview. Who has reviewed this fix?

Need a way to keep track of the model groups that have been visited. By keeping them in a stack, and then seeing if the current group has been visited, we can then determine to continue visiting the children or not, and thus prevent the stackoverflow.

Valentin will review the fix.

5. What is the risk associated with this fix?
Low. Technically, the change will only affect schemas with cyclic group references. All other schemas should be unaffected.
Comment 10 Keith Chong CLA 2008-07-30 17:36:31 EDT
Nitin/Valentin, can you please continue with the PMC approval process.

Thanks.
Comment 11 Valentin Baciu CLA 2008-07-30 18:01:27 EDT
The fix looks good. Keith consulted with Craig in creating the patch. We will try to beef up our JUnits in the Content Model area in 3.1.
Comment 12 Valentin Baciu CLA 2008-07-30 18:07:53 EDT
Nitin, PMC please review and if all is OK approve this fix. 

The fix is localized to a class that computes content model information for display in the documentation window shown to the right of the content assist drop down in the XML schema editor (and other XML-like source editors).
Comment 13 Tim deBoer CLA 2008-07-30 22:55:52 EDT
Ugly problem and simple fix. Approved.
Comment 14 Nitin Dahyabhai CLA 2008-07-30 23:07:07 EDT
Looks good to me.
Comment 15 Valentin Baciu CLA 2008-07-31 00:41:56 EDT
Seems to me the fix was committed and released to 3.0.1 builds with the tag v200807310316 and to 3.1 builds with the tag v200807310312.
Comment 16 Laurens Holst CLA 2008-07-31 04:48:44 EDT
Thanks!
Comment 17 Keith Chong CLA 2008-07-31 12:00:32 EDT
I released the fix early this morning after seeing the approval from Tim.  I was going to resolve this bug as fixed before the WTP call today.
Comment 18 Keith Chong CLA 2008-08-21 14:13:21 EDT
Verified fix in wtp-R-3.0.1-20080818032401.  Laurens, can you please verify and close this bug?
Comment 19 Laurens Holst CLA 2008-08-26 05:56:17 EDT
I have tried this in WTP 3.0.1 released on the update servers, and can verify that this is fixed, I no longer get stack errors when using our XHTML schema.

Thanks!
Comment 20 Laurens Holst CLA 2008-09-01 06:12:50 EDT
Found a new, similar bug in WTP 3.0.1, probably related. Bug 245851.