Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 319226 - XSL source editing eats GDI handles and may lead to a 'No more handles' exception
Summary: XSL source editing eats GDI handles and may lead to a 'No more handles' excep...
Status: RESOLVED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xsl (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 critical with 2 votes (vote)
Target Milestone: Future   Edit
Assignee: David Carver CLA
QA Contact: David Carver CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 323316
  Show dependency tree
 
Reported: 2010-07-08 04:13 EDT by Petrus Bergman CLA
Modified: 2010-08-21 19:30 EDT (History)
5 users (show)

See Also:


Attachments
Proposed patch to help reduce number of times Image is created (20.16 KB, patch)
2010-07-09 16:52 EDT, David Carver CLA
no flags Details | Diff
log of my workspace after helios crashed (46.03 KB, text/plain)
2010-07-16 08:01 EDT, Michael Heß CLA
no flags Details
log 2 of my workspace after helios crashed (30.75 KB, text/plain)
2010-07-16 08:02 EDT, Michael Heß CLA
no flags Details
image leak in JFaceNodeAdapter (3.03 KB, patch)
2010-08-19 11:37 EDT, Nick Sandonato CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Petrus Bergman CLA 2010-07-08 04:13:22 EDT
Build Identifier: 20100617-1415

I recently downloaded and installed Eclipse Helios for PHP developers to work with some xsl files. I'm running the Windows 64 Bit version on Windows 7 and JDK 1.6.0_21 (x64).

During a few hours work I got several crashes where Eclipse either freezed or just died. In the log file I could find exceptions like the following:

!ENTRY org.eclipse.ui 4 4 2010-07-08 08:41:05.539
!MESSAGE An internal error has occurred.
!STACK 0
org.eclipse.swt.SWTError: No more handles
	at org.eclipse.swt.SWT.error(SWT.java:4109)
	at org.eclipse.swt.SWT.error(SWT.java:3998)
	at org.eclipse.swt.SWT.error(SWT.java:3969)
	at org.eclipse.swt.widgets.Display.internal_new_GC(Display.java:2589)
	at org.eclipse.swt.graphics.Device.getDepth(Device.java:447)
	at org.eclipse.swt.custom.CTabFolder.setSelectionBackground(CTabFolder.java:2857)
	at org.eclipse.ui.internal.presentations.PaneFolder.setSelectionBackground(PaneFolder.java:772)
	at org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder.updateColors(DefaultTabFolder.java:468)
	at org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder.setActive(DefaultTabFolder.java:420)
	at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.setActive(TabbedStackPresentation.java:372)
	at org.eclipse.ui.internal.DefaultStackPresentationSite.setActive(DefaultStackPresentationSite.java:55)
	at org.eclipse.ui.internal.PartStack.setActive(PartStack.java:1183)
	at org.eclipse.ui.internal.EditorPane.showFocus(EditorPane.java:140)
	at org.eclipse.ui.internal.WorkbenchPage.deactivatePart(WorkbenchPage.java:1731)
	at org.eclipse.ui.internal.WorkbenchPage.setActivePart(WorkbenchPage.java:3523)
	at org.eclipse.ui.internal.WorkbenchPage.makeActive(WorkbenchPage.java:1244)
	at org.eclipse.ui.internal.WorkbenchPage.onDeactivate(WorkbenchPage.java:2642)
	at org.eclipse.ui.internal.WorkbenchWindow$27.run(WorkbenchWindow.java:2972)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.WorkbenchWindow.setActivePage(WorkbenchWindow.java:2967)
	at org.eclipse.ui.internal.WorkbenchWindow.closeAllPages(WorkbenchWindow.java:849)
	at org.eclipse.ui.internal.WorkbenchWindow.hardClose(WorkbenchWindow.java:1696)
	at org.eclipse.ui.internal.WorkbenchWindow.busyClose(WorkbenchWindow.java:734)
	at org.eclipse.ui.internal.WorkbenchWindow.access$0(WorkbenchWindow.java:710)
	at org.eclipse.ui.internal.WorkbenchWindow$5.run(WorkbenchWindow.java:826)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.WorkbenchWindow.close(WorkbenchWindow.java:824)
	at org.eclipse.jface.window.WindowManager.close(WindowManager.java:109)
	at org.eclipse.ui.internal.Workbench$18.run(Workbench.java:1105)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.Workbench.busyClose(Workbench.java:1102)
	at org.eclipse.ui.internal.Workbench.access$15(Workbench.java:1031)
	at org.eclipse.ui.internal.Workbench$25.run(Workbench.java:1275)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.Workbench.close(Workbench.java:1273)
	at org.eclipse.ui.internal.WorkbenchConfigurer.emergencyClose(WorkbenchConfigurer.java:165)
	at org.eclipse.ui.internal.ide.IDEWorkbenchErrorHandler.closeWorkbench(IDEWorkbenchErrorHandler.java:253)
	at org.eclipse.ui.internal.ide.IDEWorkbenchErrorHandler.handleException(IDEWorkbenchErrorHandler.java:155)
	at org.eclipse.ui.internal.ide.IDEWorkbenchErrorHandler.access$0(IDEWorkbenchErrorHandler.java:146)
	at org.eclipse.ui.internal.ide.IDEWorkbenchErrorHandler$1.runInUIThread(IDEWorkbenchErrorHandler.java:121)
	at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:95)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1383)

I opened the Task Manager in Windows and kept an eye on the GDI Object count as I once again started up Eclipse to see what was wrong with it. It was then I realise that whenever I am editing an xsl file (using either the XSL Editor or XML Editor), the GDI Object counter increased with at least one for each and every key press. It seems that when I use the PHP perspective, each key press results in one extra GDI object, but when I use the XML perspective, each key press results in about three extra GDI objects.

Eventually the GDI objects reaches the limit of 10000 and Eclipse either freezes och crashes depending on the state it is in when reaching the limit.

I cannot see the same behaviour when editing xml files or when editing xsl using the plain text editor.

Reproducible: Always

Steps to Reproduce:
1. Create a new xsl file
2. Open the xsl file with the XSL Editor
3. Write anything in the xsl file. Each added character will increase the number of allocated GDI objects. (Switch to the XML perspective to make the GDI allocation increase even faster)
4. Keep writing until the number of GDI objects reaches the upper limit for a process, i.e 10000 in Windows 7.
5. Eclipse will freeze or crash.
Comment 1 David Carver CLA 2010-07-08 14:23:08 EDT
Hmm...we'll see what we can do to track this down.  If we come up with a fix we'll try and back port as well to 3.2.2 maintenance release.

Adding Jesper on this as well.
Comment 2 David Carver CLA 2010-07-09 16:52:20 EDT
Created attachment 173920 [details]
Proposed patch to help reduce number of times Image is created

The following is a slight refactoring of the code that retrieves the image to be displayed during content assistance, outline view, and xpath views.

This tries to reduce the number of times the image is created, and tries to reuse the same image if possible.  This also cleans the code up a bit and reduces some repetition.
Comment 3 Petrus Bergman CLA 2010-07-10 22:10:35 EDT
(In reply to comment #2)

I downloaded the source and compiled a new jar with the patch to test it. However, I still see an increase of the allocated GDI objects when I type something in the XSL editor.
Comment 4 David Carver CLA 2010-07-12 08:10:38 EDT
I think we need to apply a similar fix from bug 319226 to wst.xsl as well.
Comment 5 David Carver CLA 2010-07-12 08:27:14 EDT
(In reply to comment #4)
> I think we need to apply a similar fix from bug 319226 to wst.xsl as well.

Petrus, please try getting the latest wst.xml.ui, wst.xml.core, wst.sse.ui, and wst.sse.core code out as well, and see if the patch in bug 319226 improves anything for you. (this should already be applied).

The reason you may see an increase in the leakage in the GDI is due to the image leaks that were occuring in the CMImageUtil class for xml.ui.   If from the XML Perspective you close both the Outline View and the XPath View, does the image leak continue?

These two views make use of the CMImageUtil to help return the image that should appear on the nodes, and everytime you type or press a key, these views are updated.
Comment 6 Michael Heß CLA 2010-07-16 08:01:15 EDT
I am seeing this as well. Tough I could not have pinpointed it that exactly. :-/

What I am experiencing is, that for the last 2 days I had to work with XSL/XSD files. And ever since this type of work started, I have Helios crashing.

I have the logs from the workspace, including the stacks which were written to the log. I will attach them - maybe someone get something useful out of them.
Comment 7 Michael Heß CLA 2010-07-16 08:01:52 EDT
Created attachment 174481 [details]
log of my workspace after helios crashed
Comment 8 Michael Heß CLA 2010-07-16 08:02:08 EDT
Created attachment 174482 [details]
log 2 of my workspace after helios crashed
Comment 9 David Carver CLA 2010-07-16 08:40:05 EDT
http://build.eclipse.org/webtools/committers/wtp-R3.2.1-M/20100715212701/M-3.2.1-20100715212701/

You may want to try using the 3.2.1 maintenance release Integration build to help determine if the patch for the prior bug mentioned fixes this issue.
Comment 10 Sam Bernet CLA 2010-08-19 08:36:14 EDT
(In reply to comment #9)
> http://build.eclipse.org/webtools/committers/wtp-R3.2.1-M/20100715212701/M-3.2.1-20100715212701/

Hi,

Above link seems to be outdated, so I did only install the current version of the XSL Dev Tools:

Eclipse XSL Developer Tools	1.1.1.v201007132152-7S7WFANFIpS-0-NXEE5pifZBQLO

Should I try something else?
Comment 11 Sam Bernet CLA 2010-08-19 08:42:01 EDT
(In reply to comment #10)

> Above link seems to be outdated, so I did only install the current version of
> the XSL Dev Tools:
> 
> Eclipse XSL Developer Tools    1.1.1.v201007132152-7S7WFANFIpS-0-NXEE5pifZBQLO

Which does not have any impact, I forgot to mention.
Comment 12 Sam Bernet CLA 2010-08-19 08:54:36 EDT
A few more interesting observations:

1) If I close the Outline and XPath View in the XML perspective, then restart Eclipse and edit XSL files, the leak does NOT occur.

2) If either one or both (Outline, XPath View) are open, the leak does occur. Handles are of course leaked faster if both are visible.

3) If XPath View is open but Outline is closed, and XPath View contains an expression that does not yield any results for the current XSL, the leak does NOT occur. Only if the view actually lists result nodes/trees handles start to leak again.

4) Once one of these views is opened and leaking started, closing the view does NOT solve the problem. Leakage goes on until *BANG*.

5) It's not limited to XML Perspective. If Outline view is fully collapsed, (e.g. only root element is visible), about 3 handles per key-stroke are leaked. If I expand the list on a larger XSL, it leaks some dozens of handles per key-stroke. Again, once opened, leakage continues after closing Outline.

btw: I'm on Win XP SP2 32-bit, Eclipse Platform 3.6.0.I20100608-0911, Eclipse XML Editors and Tools 3.2.1.v201007132152-7H7AFUMDxumQGOh8tejUU2Uw_Mx0
Comment 13 David Carver CLA 2010-08-19 09:23:43 EDT
Yeah, I suspect this will happen, due to the fact that the XPath View and Outline View use much of the same code for rendering the images.   Have you tried installing Webtools 3.2.1.  It should contain a fix for some of these image leaks:

http://download.eclipse.org/webtools/downloads/

An update site with the latest changes should be available at:

http://download.eclipse.org/webtools/repository/helios/



(In reply to comment #12)
> A few more interesting observations:
> 
> 1) If I close the Outline and XPath View in the XML perspective, then restart
> Eclipse and edit XSL files, the leak does NOT occur.
> 
> 2) If either one or both (Outline, XPath View) are open, the leak does occur.
> Handles are of course leaked faster if both are visible.
> 
> 3) If XPath View is open but Outline is closed, and XPath View contains an
> expression that does not yield any results for the current XSL, the leak does
> NOT occur. Only if the view actually lists result nodes/trees handles start to
> leak again.
> 
> 4) Once one of these views is opened and leaking started, closing the view does
> NOT solve the problem. Leakage goes on until *BANG*.
> 
> 5) It's not limited to XML Perspective. If Outline view is fully collapsed,
> (e.g. only root element is visible), about 3 handles per key-stroke are leaked.
> If I expand the list on a larger XSL, it leaks some dozens of handles per
> key-stroke. Again, once opened, leakage continues after closing Outline.
> 
> btw: I'm on Win XP SP2 32-bit, Eclipse Platform 3.6.0.I20100608-0911, Eclipse
> XML Editors and Tools 3.2.1.v201007132152-7H7AFUMDxumQGOh8tejUU2Uw_Mx0
Comment 14 David Carver CLA 2010-08-19 09:34:00 EDT
Nick you fixed a similar issue recently in XML, mind taking a peak at the XSL code to see if you can locate the cause, or should this be fixed by the change that went into 3.2.1?
Comment 15 Sam Bernet CLA 2010-08-19 10:32:52 EDT
I can confirm 3.2.1 does NOT fix or improve the issue. It takes me about one minute of writing nonsense to have eclipse freeze.
Comment 16 Nick Sandonato CLA 2010-08-19 11:37:15 EDT
Created attachment 177016 [details]
image leak in JFaceNodeAdapter

Looks like the JFaceNodeAdapter was creating an unmanaged image quite frequently. For example, if you're in the <xsl:template> tag and you start typing freely, the outline view is being refreshed frequently, and you're creating a lot of images.
Comment 17 Nick Sandonato CLA 2010-08-19 11:38:06 EDT
(In reply to comment #15)
> I can confirm 3.2.1 does NOT fix or improve the issue. It takes me about one
> minute of writing nonsense to have eclipse freeze.

Sam is right. My fix did not address this in 3.2.1 for XSL.
Comment 18 Jesper Moller CLA 2010-08-19 16:58:24 EDT
(In reply to comment #17)
> (In reply to comment #15)
> > I can confirm 3.2.1 does NOT fix or improve the issue. It takes me about one
> > minute of writing nonsense to have eclipse freeze.
> 
> Sam is right. My fix did not address this in 3.2.1 for XSL.

We should be able to fix this for 3.2.2. Nick, does your latest patch fix the issue?
Comment 19 Nick Sandonato CLA 2010-08-20 14:00:47 EDT
(In reply to comment #18)
> (In reply to comment #17)
> > (In reply to comment #15)
> > > I can confirm 3.2.1 does NOT fix or improve the issue. It takes me about one
> > > minute of writing nonsense to have eclipse freeze.
> > 
> > Sam is right. My fix did not address this in 3.2.1 for XSL.
> 
> We should be able to fix this for 3.2.2. Nick, does your latest patch fix the
> issue?

As far as I could tell, yes. I switched to the XML perspective and started typing text content in the xsl:template element. Without the patch, I saw the GDI Object count increase while typing. With the patch, the number stayed constant. This should address the specific scenario that Sam discusses.
Comment 20 David Carver CLA 2010-08-21 19:30:52 EDT
Thanks for the patch Nick.  I've released this into both HEAD and the R3_2_maintenance branch.   R3_2_maintenance fix is tracked up bug 323316.