Bug 305341 - [Perspectives] [FastView] [ActivityMgmt] IndexOutOfBoundsException in org.eclipse.ui.internal.PartStack.replace(PartStack.java:914)
Summary: [Perspectives] [FastView] [ActivityMgmt] IndexOutOfBoundsException in org.ecl...
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5.2   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-10 10:59 EST by Andre Ribeiro CLA
Modified: 2019-09-06 16:08 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andre Ribeiro CLA 2010-03-10 10:59:25 EST
Build Identifier: M20100211-1343

The org.eclipse.ui.internal.PartStack.replace(LayoutPart, LayoutPart) method assumes that:
[line 904] int idx = children.indexOf(oldChild);

returns a valid number to use at line 914 of the same method:
[line 914] children.add(idx, newChild);

However if one is using activities (org.eclipse.ui.activities extension point) to filter certain Workbench Parts it is possible that this does not hold true.

This is very hard to reproduce since it involves concurrent conditions between the activities mechanism and the PartStack methods.

Stacktrace:
!ENTRY org.eclipse.ui 4 0 2010-03-10 15:41:35.787
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.IndexOutOfBoundsException: Index: -1, Size: 1
	at java.util.ArrayList.add(ArrayList.java:367)
	at org.eclipse.ui.internal.PartStack.replace(PartStack.java:914)
	at org.eclipse.ui.internal.PerspectiveHelper.removePart(PerspectiveHelper.java:1231)
	at org.eclipse.ui.internal.Perspective.addFastView(Perspective.java:204)
	at org.eclipse.ui.internal.Perspective.makeFastView(Perspective.java:189)
	at org.eclipse.ui.internal.WorkbenchPage.makeFastView(WorkbenchPage.java:665)
	at org.eclipse.ui.internal.FastViewManager.makeFast(FastViewManager.java:376)
	at org.eclipse.ui.internal.FastViewManager.addViewReference(FastViewManager.java:257)
	at org.eclipse.ui.handlers.ShowViewHandler.openView(ShowViewHandler.java:147)
	at org.eclipse.ui.handlers.ShowViewHandler.execute(ShowViewHandler.java:80)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:294)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
	at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
	at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(CommandContributionItem.java:770)
	at org.eclipse.ui.menus.CommandContributionItem.access$10(CommandContributionItem.java:756)
	at org.eclipse.ui.menus.CommandContributionItem$5.handleEvent(CommandContributionItem.java:746)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3880)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3473)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at com.criticalsoftware.workbench.Application.start(Application.java:21)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
	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:368)
	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:559)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1287)



Reproducible: Always

Steps to Reproduce:
This exception is not trivial to reproduce, since it needs concurrent enablement /disablement of activities while the org.eclipse.ui.handlers.ShowViewHandler.openView() executes.

Or at least this is what i think ... See the stacktrace for details.
Comment 1 Andre Ribeiro CLA 2010-03-10 13:36:47 EST
there's an additional exception I'm getting along with the one previously reported.

I should mention that these exceptions are thrown when attempting to show views either from the fastviews menus or the main menu bar (particularly in my tests the LogView).


Stacktrace:
!ENTRY org.eclipse.ui 4 0 2010-03-10 18:29:33.100
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NullPointerException
	at org.eclipse.ui.internal.PerspectiveHelper.removePart(PerspectiveHelper.java:1277)
	at org.eclipse.ui.internal.Perspective.addFastView(Perspective.java:204)
	at org.eclipse.ui.internal.Perspective.makeFastView(Perspective.java:189)
	at org.eclipse.ui.internal.WorkbenchPage.makeFastView(WorkbenchPage.java:665)
	at org.eclipse.ui.internal.FastViewManager.makeFast(FastViewManager.java:376)
	at org.eclipse.ui.internal.FastViewManager.addViewReference(FastViewManager.java:257)
	at org.eclipse.ui.handlers.ShowViewHandler.openView(ShowViewHandler.java:147)
	at org.eclipse.ui.handlers.ShowViewHandler.execute(ShowViewHandler.java:80)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:294)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
	at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
	at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(CommandContributionItem.java:770)
	at org.eclipse.ui.menus.CommandContributionItem.access$10(CommandContributionItem.java:756)
	at org.eclipse.ui.menus.CommandContributionItem$5.handleEvent(CommandContributionItem.java:746)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3880)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3473)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at com.criticalsoftware.workbench.Application.start(Application.java:21)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
	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:368)
	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:559)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Comment 2 Eric Moffatt CLA 2010-04-07 09:53:02 EDT
Andre, can you give us a flavor of the types of concurrency issues you allude to in the 'to repro' comments?

Is there some background task changing the activities in a background thread while you're doing this? If not could you provide an outline of what you think is happening?
Comment 3 Andre Ribeiro CLA 2010-04-07 10:28:52 EDT
yes, in my app is possible for a background thread to change the activities (that filter the visibility of certain workbench parts) while the user may be opening the fast view menu to open the same workbench parts.
Comment 4 Eric Moffatt CLA 2010-04-07 11:00:18 EDT
My suggestion would be to move the code that is changing activities onto the UI thread using either 'synchExec' or 'asynchExec'. This will likely prevent this particular scenario from occurring. 

It will not, however, prevent your users from becoming confused when the view they just opened disappears...;-).
Comment 5 Andre Ribeiro CLA 2010-04-07 11:03:15 EDT
is that a "won't fix"? :)
Comment 6 Eric Moffatt CLA 2010-04-07 11:29:02 EDT
Not really so much, just a suggestion to hopefully get you going again...

Making the complete UI API thread-safe (or IMO even this part of it) isn't likely to happen in 3.6 though...how about 'unlikely'...;-).
Comment 7 Eclipse Webmaster CLA 2019-09-06 16:08:12 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.