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

Bug 361360

Summary: CME in PageSite.activate
Product: [Eclipse Project] Platform Reporter: Linuxhippy <linuxhippy>
Component: UIAssignee: Dean Roberts <dean.t.roberts>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: pwebster, remy.suen
Version: 3.7.1Flags: pwebster: review+
Target Milestone: 3.7.2   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Fix CME none

Description Linuxhippy CLA 2011-10-19 05:29:15 EDT
Build Identifier: M20110909-1335

While working with java-code I got the following Exception:

java.util.ConcurrentModificationException
	at java.util.HashMap$HashIterator.nextEntry(HashMap.java:806)
	at java.util.HashMap$KeyIterator.next(HashMap.java:841)
	at org.eclipse.ui.internal.handlers.NestableHandlerService.activate(NestableHandlerService.java:67)
	at org.eclipse.ui.internal.services.ServiceLocator.activate(ServiceLocator.java:115)
	at org.eclipse.ui.part.PageSite.activate(PageSite.java:221)
	at org.eclipse.ui.part.PageBookView.showPageRec(PageBookView.java:984)
	at org.eclipse.ui.views.contentoutline.ContentOutline.showPageRec(ContentOutline.java:251)
	at org.eclipse.ui.part.PageBookView.partActivated(PageBookView.java:756)
	at org.eclipse.ui.views.contentoutline.ContentOutline.partBroughtToTop(ContentOutline.java:212)
	at org.eclipse.ui.part.PageBookView$4.partBroughtToTop(PageBookView.java:1018)
	at org.eclipse.ui.internal.PartListenerList2$2.run(PartListenerList2.java:85)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.runtime.Platform.run(Platform.java:888)
	at org.eclipse.ui.internal.PartListenerList2.fireEvent(PartListenerList2.java:55)
	at org.eclipse.ui.internal.PartListenerList2.firePartBroughtToTop(PartListenerList2.java:83)
	at org.eclipse.ui.internal.PartService.firePartBroughtToTop(PartService.java:212)
	at org.eclipse.ui.internal.WorkbenchPagePartList.firePartBroughtToTop(WorkbenchPagePartList.java:76)
	at org.eclipse.ui.internal.WorkbenchPagePartList.fireActiveEditorChanged(WorkbenchPagePartList.java:52)
	at org.eclipse.ui.internal.PartList.setActiveEditor(PartList.java:162)
	at org.eclipse.ui.internal.WorkbenchPage.makeActiveEditor(WorkbenchPage.java:1355)
	at org.eclipse.ui.internal.WorkbenchPage.setActivePart(WorkbenchPage.java:3629)
	at org.eclipse.ui.internal.WorkbenchPage.requestActivation(WorkbenchPage.java:3159)
	at org.eclipse.ui.internal.PartPane.requestActivation(PartPane.java:279)
	at org.eclipse.ui.internal.EditorPane.requestActivation(EditorPane.java:98)
	at org.eclipse.ui.internal.PartPane.setFocus(PartPane.java:325)
	at org.eclipse.ui.internal.EditorPane.setFocus(EditorPane.java:127)
	at org.eclipse.ui.internal.PartStack.presentationSelectionChanged(PartStack.java:837)
	at org.eclipse.ui.internal.PartStack.access$1(PartStack.java:823)
	at org.eclipse.ui.internal.PartStack$1.selectPart(PartStack.java:137)
	at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation$1.handleEvent(TabbedStackPresentation.java:133)
	at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:269)
	at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:278)
	at org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder.access$1(DefaultTabFolder.java:1)
	at org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder$2.handleEvent(DefaultTabFolder.java:88)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1282)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1267)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1061)
	at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:2745)
	at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1432)
	at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:257)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3588)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3209)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
	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:344)
	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:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)


Reproducible: Didn't try
Comment 1 Linuxhippy CLA 2011-10-27 07:01:05 EDT
anybody?
Comment 2 Remy Suen CLA 2011-10-27 07:03:26 EDT
(In reply to comment #1)
> anybody?

Are you able to reproduce this problem consistently?
Comment 3 Linuxhippy CLA 2011-10-27 07:08:15 EDT
no, but by looking at the source it should be possible to find out which collection entity has been modified concurrently.
CME exceptions typically aren't reproduceable.
Comment 4 Paul Webster CLA 2011-10-27 10:02:13 EDT
Dean, could you please have a look for 3.7.2?

PW
Comment 5 Dean Roberts CLA 2011-11-04 10:33:54 EDT
Created attachment 206464 [details]
Fix CME

This change could mean that an activation will get fired, even if a deactivastion happened while the service was busy activating all the handlers it knows about.

The patch includes a piece of guard code to minimize the window where this could happen, but there is still a timing hole.

However, I believe that trying to close the timing hole properly would create a dead lock prone mess of synchronized calls.

I believe that, while not perfect, the fix performs better than the existing code where a CME is thrown and an undetermined number of handlers are not activated.
Comment 8 Paul Webster CLA 2012-01-31 13:47:20 EST
In M20120127-0800
PW