Bug 575616 - OutOfMemoryError on part creation results in exceptions or hang during start-up
Summary: OutOfMemoryError on part creation results in exceptions or hang during start-up
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.15   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 4.22 M1   Edit
Assignee: Simeon Andreev CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-25 04:42 EDT by Simeon Andreev CLA
Modified: 2021-09-28 04:44 EDT (History)
5 users (show)

See Also:


Attachments
Error log from sessions leading to the hang. (71.91 KB, text/plain)
2021-08-26 02:56 EDT, Simeon Andreev CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Simeon Andreev CLA 2021-08-25 04:42:43 EDT
Seen in our products logs, so far we don't know how to reproduce it. The deadlocked threads are:



"Framework stop" #71 prio=6 os_prio=0 tid=0x00007f5f41c8a800 nid=0xc39e in Object.wait() [0x00007f52b3425000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at java.lang.Object.wait(Object.java:502)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:253)
	- locked <0x00007f5b889300f8> (a org.eclipse.swt.widgets.RunnableLock)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:146)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:6018)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:219)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38)
	at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:205)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:203)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151)
	at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:132)
	at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:75)
	at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:44)
	at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:55)
	at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:63)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:424)
	at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(EcoreEList.java:249)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.remove(NotifyingListImpl.java:713)
	at org.eclipse.emf.common.util.AbstractEList.remove(AbstractEList.java:456)
	at org.eclipse.emf.common.util.BasicEMap.remove(BasicEMap.java:1751)
	at org.eclipse.emf.common.util.BasicEMap.removeKey(BasicEMap.java:628)
	at org.eclipse.emf.common.util.BasicEMap$DelegatingMap.remove(BasicEMap.java:798)
	at org.eclipse.e4.ui.internal.workbench.OpaqueElementUtil.clearOpaqueItem(OpaqueElementUtil.java:50)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityView.clearOpaqueMenuItems(CompatibilityView.java:240)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityView.disposeSite(CompatibilityView.java:273)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.internalDisposeSite(CompatibilityPart.java:430)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.invalidate(CompatibilityPart.java:268)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.destroy(CompatibilityPart.java:417)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:1001)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:966)
	at org.eclipse.e4.core.internal.di.InjectorImpl.disposed(InjectorImpl.java:462)
	at org.eclipse.e4.core.internal.di.Requestor.disposed(Requestor.java:160)
	at org.eclipse.e4.core.internal.contexts.ContextObjectSupplier$ContextInjectionListener.update(ContextObjectSupplier.java:82)
	at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:106)
	at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.handleInvalid(TrackableComputationExt.java:69)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.dispose(EclipseContext.java:186)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.dispose(EclipseContext.java:171)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.dispose(EclipseContext.java:171)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.dispose(EclipseContext.java:171)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.dispose(EclipseContext.java:171)
	at org.eclipse.e4.core.internal.contexts.osgi.EclipseContextOSGi.dispose(EclipseContextOSGi.java:102)
	at org.eclipse.e4.core.internal.contexts.osgi.EclipseContextOSGi.bundleChanged(EclipseContextOSGi.java:144)
	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:973)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151)
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:234)
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:140)
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:132)
	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:231)
	at org.eclipse.osgi.container.Module.publishEvent(Module.java:493)
	at org.eclipse.osgi.container.Module.doStop(Module.java:651)
	at org.eclipse.osgi.container.Module.stop(Module.java:515)
	at org.eclipse.osgi.container.SystemModule.stop(SystemModule.java:207)
	at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule$1.run(EquinoxBundle.java:220)
	at java.lang.Thread.run(Thread.java:748)

"main" #1 prio=6 os_prio=0 tid=0x00007f5f4004f800 nid=0xc168 in Object.wait() [0x00007f5f47d9d000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at org.eclipse.osgi.container.SystemModule.waitForStop(SystemModule.java:173)
	- locked <0x00007f53304c01d8> (a java.util.concurrent.atomic.AtomicReference)
	at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle.waitForStop(EquinoxBundle.java:306)
	at org.eclipse.osgi.launch.Equinox.waitForStop(Equinox.java:198)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.shutdown(EclipseStarter.java:456)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:274)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:660)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:597)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1468)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1441)

I'll try to reproduce, meanwhile feedback is welcome.
Comment 1 Thomas Watson CLA 2021-08-25 08:49:18 EDT
Moving to Platform->UI for comment

The main thread has exited from the workbench (org.eclipse.ui.PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor)).  Therefore there is no longer a UI thread to do the following:

org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec

org.eclipse.ui.PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor)

If this is really from 4.15 then perhaps this is already fixed in a later release.  I suggest trying with the latest release.
Comment 2 Rolf Theunissen CLA 2021-08-26 02:20:01 EDT
1. It seems odd that a CompatibilityView is still not disposed, even though the main thread is stopped, also it doesn't run in the UI thread.
2. Although this code should not be running here, and might throw an error later, the display is not disposed. So it is valid to call the Display.synExec() method.

On Linux, the Display.syncExec() method first acquires a lock on the Display/Device. Then it tries to acquire a lock on 'idleLock', can you find in the logs where 0x00007f52b3425000 is locked?

Seems related to Bug 546743 (which is marked fixed for 4.15), moving to SWT.
Comment 3 Simeon Andreev CLA 2021-08-26 02:29:57 EDT
I'm sorry but how is this an SWT bug?

Either OSGI or platform UI code is trying to dispose UI elements from a non-UI thread, while the UI/main thread is waiting on shutdown (or has finished processing UI events). SWT has nothing to do with this; instead this looks like e4 spaghetti interacting with the UI in unexpected ways.

Looking at the error log when the hang occurred, I assume the workbench was in a broken state UI-wise. Possibly unable to start correctly. Unfortunately we don't have the workspace in which the hang occurred multiple times, maybe we'll be able to obtain it. I've also not been able to reproduce by adding manual exceptions on application start-up (what I so far assume is the trigger here).
Comment 4 Rolf Theunissen CLA 2021-08-26 02:54:35 EDT
(In reply to Simeon Andreev from comment #3)
> I'm sorry but how is this an SWT bug?
> 
> Either OSGI or platform UI code is trying to dispose UI elements from a
> non-UI thread, while the UI/main thread is waiting on shutdown (or has
> finished processing UI events). SWT has nothing to do with this; instead
> this looks like e4 spaghetti interacting with the UI in unexpected ways.


I agree that probably UI is doing something wrong here, I expect errors to be thrown, not deadlocks. That is, when UI is run on an invalid thread, ERROR_THREAD_INVALID_ACCESS should have been thrown by SWT, it doesn't. It will throw it when Synchronizer#syncExec is called, but the deadlock is before there.

This deadlock will not occur on SWT win32, because here is not second lock request in Display#syncExec.
Comment 5 Simeon Andreev CLA 2021-08-26 02:56:11 EDT
Created attachment 287020 [details]
Error log from sessions leading to the hang.

I've removed (customer/product) sensitive information from the log file, its attached now.

Up until the first logged errors, the product seems to have worked fine.
Comment 6 Simeon Andreev CLA 2021-08-26 03:00:06 EDT
(In reply to Rolf Theunissen from comment #4)
> I agree that probably UI is doing something wrong here, I expect errors to
> be thrown, not deadlocks. That is, when UI is run on an invalid thread,
> ERROR_THREAD_INVALID_ACCESS should have been thrown by SWT, it doesn't. It
> will throw it when Synchronizer#syncExec is called, but the deadlock is
> before there.
> 
> This deadlock will not occur on SWT win32, because here is not second lock
> request in Display#syncExec.

Please open an extra ticket for this. Or should I?

For this ticket, IMO the goal is to know why EclipseContextOSGi.dispose() lead to closing parts. From my debugging so far, all parts are disposed before bundles are stopped on shutdown. I was not able to create a UI part manually (as the UI is gone).

See also the log I attached, there are logged errors about invalid thread access in previous sessions. I'm guessing the workspace state got even worse after that (I still don't know what the problem actually is).
Comment 7 Rolf Theunissen CLA 2021-08-26 03:12:32 EDT
(In reply to Simeon Andreev from comment #6)
> (In reply to Rolf Theunissen from comment #4)
> > I agree that probably UI is doing something wrong here, I expect errors to
> > be thrown, not deadlocks. That is, when UI is run on an invalid thread,
> > ERROR_THREAD_INVALID_ACCESS should have been thrown by SWT, it doesn't. It
> > will throw it when Synchronizer#syncExec is called, but the deadlock is
> > before there.
> > 
> > This deadlock will not occur on SWT win32, because here is not second lock
> > request in Display#syncExec.
> 
> Please open an extra ticket for this. Or should I?
> 
> For this ticket, IMO the goal is to know why EclipseContextOSGi.dispose()
> lead to closing parts. From my debugging so far, all parts are disposed
> before bundles are stopped on shutdown. I was not able to create a UI part
> manually (as the UI is gone).
> 
> See also the log I attached, there are logged errors about invalid thread
> access in previous sessions. I'm guessing the workspace state got even worse
> after that (I still don't know what the problem actually is).

Agree that there are two issues:
1. The incorrect disposal of UI parts not on the UI thread.
2. The hang while doing the incorrect disposal.

The title of the current bug suggests that it is about 2, while you are looking into 1.
Comment 8 Simeon Andreev CLA 2021-08-26 03:41:36 EDT
> On Linux, the Display.syncExec() method first acquires a lock on the
> Display/Device. Then it tries to acquire a lock on 'idleLock', can you find
> in the logs where 0x00007f52b3425000 is locked?

The jstack output shows only 1 mention of 0x00007f52b3425000. Only the threads from the description seem to do anything / want to do anything. The rest of the thread stack traces look like standard idle stack traces.
Comment 9 Simeon Andreev CLA 2021-08-26 04:38:42 EDT
I've opened bug 575633 for the SWT behaviour in GTK.
Comment 10 Simeon Andreev CLA 2021-08-26 05:46:02 EDT
OK, the problem seems to be the OOM that occurred in a text editor at UI start-up. See attached log file, the very first logged exception:

!ENTRY org.eclipse.ui 4 4 2021-08-09 11:44:28.024
!MESSAGE Unable to create part
!STACK 1
org.eclipse.ui.PartInitException: Editor could not be initialized.
	at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3187)
	at org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTextEditor.java:3196)
	at org.eclipse.ui.internal.EditorReference.initialize(EditorReference.java:354)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:340)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:1001)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:966)
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalInject(InjectorImpl.java:139)
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:411)
	at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:333)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:202)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:91)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:60)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:42)
	at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:132)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:1015)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:675)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:781)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:752)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:746)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:730)
	at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.showTab(StackRenderer.java:1298)
	at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.lambda$0(LazyStackRenderer.java:75)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler.lambda$0(UIEventHandler.java:38)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:236)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:146)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:6018)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:219)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38)
	at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:205)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:203)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151)
	at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:132)
	at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:75)
	at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:44)
	at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:55)
	at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:63)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:424)
	at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElementGen(ElementContainerImpl.java:170)
	at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElement(ElementContainerImpl.java:188)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:652)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:616)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.delegateBringToTop(PartServiceImpl.java:791)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.bringToTop(PartServiceImpl.java:404)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:1240)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:3211)
	at org.eclipse.ui.internal.WorkbenchPage.lambda$9(WorkbenchPage.java:3116)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:72)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3114)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3085)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3068)
	at org.eclipse.ui.ide.IDE.openEditorOnFileStore(IDE.java:1382)
	at org.eclipse.ui.internal.ide.actions.OpenLocalFileAction.run(OpenLocalFileAction.java:100)
	at org.eclipse.ui.internal.ide.actions.OpenLocalFileAction.run(OpenLocalFileAction.java:73)
	at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:232)
	at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:218)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:580)
	at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:412)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5874)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1405)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:5138)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4663)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1173)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1062)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:657)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:556)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at com.verigy.itee.ui.SmarTestIdeApplication.start(SmarTestIdeApplication.java:124)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:660)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:597)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1468)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1441)
Caused by: java.lang.OutOfMemoryError
	at java.lang.AbstractStringBuilder.hugeCapacity(AbstractStringBuilder.java:161)
	at java.lang.AbstractStringBuilder.newCapacity(AbstractStringBuilder.java:155)
	at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:125)
	at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:596)
	at java.lang.StringBuilder.append(StringBuilder.java:190)
	at org.eclipse.core.internal.filebuffers.FileStoreTextFileBuffer.setDocumentContent(FileStoreTextFileBuffer.java:538)
	at org.eclipse.core.internal.filebuffers.FileStoreTextFileBuffer.initializeFileBufferContent(FileStoreTextFileBuffer.java:319)
	at org.eclipse.core.internal.filebuffers.FileStoreFileBuffer.create(FileStoreFileBuffer.java:66)
	at org.eclipse.core.internal.filebuffers.TextFileBufferManager.connectFileStore(TextFileBufferManager.java:150)
	at org.eclipse.ui.editors.text.TextFileDocumentProvider.createFileInfo(TextFileDocumentProvider.java:571)
	at org.eclipse.ui.editors.text.TextFileDocumentProvider.connect(TextFileDocumentProvider.java:481)
	at org.eclipse.ui.texteditor.AbstractTextEditor.doSetInput(AbstractTextEditor.java:4187)
	at org.eclipse.ui.texteditor.StatusTextEditor.doSetInput(StatusTextEditor.java:260)
	at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.doSetInput(AbstractDecoratedTextEditor.java:1477)
	at org.eclipse.ui.editors.text.TextEditor.doSetInput(TextEditor.java:153)
	at org.eclipse.ui.texteditor.AbstractTextEditor.lambda$1(AbstractTextEditor.java:3154)
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:438)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:354)
	at org.eclipse.ui.internal.WorkbenchWindow.lambda$5(WorkbenchWindow.java:2419)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:72)
	at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2417)
	at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3171)
	... 91 more

Reproduction steps are trivial on 4.15:

1. Add this to simulate the OOM (alternatively a file will have to be rather big, e.g. we had the same exception in another case, not at start-up, due to opening a 8.4 GB file):
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileStoreTextFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileStoreTextFileBuffer.java
index 289de5dcf..216ee0563 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileStoreTextFileBuffer.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileStoreTextFileBuffer.java
@@ -534,6 +534,9 @@ public class FileStoreTextFileBuffer extends FileStoreFileBuffer implements ITex
                        int n= in.read(readBuffer);
                        while (n > 0) {
                                buffer.append(readBuffer, 0, n);
+                               if (buffer.toString().contains("special string to cause OOM")) {
+                                       throw new java.lang.OutOfMemoryError();
+                               }
                                n= in.read(readBuffer);
                        }
 

2. Start Eclipse in a new workspace.
3. Open an empty text file with a text editor.
4. Close Eclipse.
5. Ensure the OOM is hit, either by adding a lot of content to the text file, or the special string above.
6. Start Eclipse again in the same workspace (from step 2.).
7. Observe the hang.

On 4.21, it seems this results in a NPE. Might be a question of timing though, I'm not sure; the attached log has also such exceptions prior to when the hang occurred:

!ENTRY org.eclipse.e4.ui.workbench 4 0 2021-08-26 11:41:34.700
!MESSAGE 
!STACK 0
java.lang.NullPointerException
	at org.eclipse.jface.resource.JFaceResources.getResources(JFaceResources.java:214)
	at org.eclipse.jface.resource.JFaceResources.getResources(JFaceResources.java:232)
	at org.eclipse.ui.part.WorkbenchPart.dispose(WorkbenchPart.java:105)
	at org.eclipse.ui.texteditor.AbstractTextEditor.dispose(AbstractTextEditor.java:4442)
	at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.dispose(AbstractDecoratedTextEditor.java:392)
	at org.eclipse.ui.editors.text.TextEditor.dispose(TextEditor.java:94)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.invalidate(CompatibilityPart.java:264)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.destroy(CompatibilityPart.java:421)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:995)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:960)
	at org.eclipse.e4.core.internal.di.InjectorImpl.disposed(InjectorImpl.java:452)
	at org.eclipse.e4.core.internal.di.Requestor.disposed(Requestor.java:161)
	at org.eclipse.e4.core.internal.contexts.ContextObjectSupplier$ContextInjectionListener.update(ContextObjectSupplier.java:83)
	at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:103)
	at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.handleInvalid(TrackableComputationExt.java:68)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.dispose(EclipseContext.java:186)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.dispose(EclipseContext.java:171)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.dispose(EclipseContext.java:171)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.dispose(EclipseContext.java:171)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.dispose(EclipseContext.java:171)
	at org.eclipse.e4.core.internal.contexts.osgi.EclipseContextOSGi.dispose(EclipseContextOSGi.java:102)
	at org.eclipse.e4.core.internal.contexts.osgi.EclipseContextOSGi.bundleChanged(EclipseContextOSGi.java:144)
	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:935)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:228)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151)
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:229)
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:138)
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:130)
	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:206)
	at org.eclipse.osgi.container.Module.publishEvent(Module.java:499)
	at org.eclipse.osgi.container.Module.doStop(Module.java:658)
	at org.eclipse.osgi.container.Module.stop(Module.java:521)
	at org.eclipse.osgi.container.SystemModule.stop(SystemModule.java:207)
	at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule.lambda$0(EquinoxBundle.java:224)
	at java.base/java.lang.Thread.run(Thread.java:834)
Comment 11 Simeon Andreev CLA 2021-08-26 05:52:48 EDT
Note that Eclipse is unusable after the OOM. Hang or exception, it doesn't come up anymore.

Is this due to the type of exception (OOM)? I see the code in core.buffers rethrows a CoreException on an IOException. If I throw an IOException instead of an OOM, the text of the IOException is seen in the editor and the UI is able to come up.

Should I move this to platform.text? IMO platform.ui should be more durable to any type of exception that flies at start-up. There might be RuntimeException, NullPointerException, OutOfMemoryError and so on from other places also.
Comment 12 Simeon Andreev CLA 2021-08-26 06:58:52 EDT
I've opened bug 575641 for handling OOM exceptions (and possibly other types of exceptions) in platform.text ResourceTextFileBuffer.setDocumentContent().
Comment 13 Eclipse Genie CLA 2021-08-26 07:01:39 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/184447