Project: Eclipse_Platform_UI
Bug 236612 [ActivityMgmt] Endless loop in MutableActivityManager.getIdentifier(..)
Reported: 2008-06-11 08:38:37 | Status: verified fixed

I20080609-1311, Sun JDK 1.6.0_05-b13 This never happened to me before, but now I ran into this the second time in two days. Both times, I was working in my development workbench and pressed Ctrl+H to open the search dialog. The UI thread froze, CPU went up to 100% on one core, and stack dumps always looked like the one below. From another Eclipse instance, I attached the debugger to the running Eclipse. With some debugging using the Display view, I found that the data in the WeakHashMap was screwed up. The table contained several WeakHashMap.Entry objects whose 'next' field formed cycles (i.e. for Entry e, e.next.next was the same as e). I don't quite understand why MutableActivityManager#activitiesById must be a WeakHashMap. However, I think it's not safe to even just read a WeakHashMap from multiple threads without synchronization (e.g. from the UI thread and from MutableActivityManager.getUpdateJob().new Job() {...}.run(IProgressMonitor)), since every WeakHashMap#get() may cause a structural change (via getTable() -> expungeStaleEntries()). "main" prio=6 tid=0x00397000 nid=0xa58 runnable [0x009de000..0x009dfe68] java.lang.Thread.State: RUNNABLE at java.util.WeakHashMap.get(WeakHashMap.java:355) at org.eclipse.ui.internal.activities.MutableActivityManager.getIdentifier(MutableActivityManager.java:186) at org.eclipse.ui.internal.activities.ProxyActivityManager.getIdentifier(ProxyActivityManager.java:76) at org.eclipse.ui.activities.WorkbenchActivityHelper.filterItem(WorkbenchActivityHelper.java:218) at org.eclipse.search.internal.ui.SearchDialog.filterByActivities(SearchDialog.java:339) at org.eclipse.search.internal.ui.SearchDialog.<init>(SearchDialog.java:152) at org.eclipse.search.internal.ui.OpenSearchDialogAction.run(OpenSearchDialogAction.java:53) at org.eclipse.search.internal.ui.OpenSearchDialogAction.run(OpenSearchDialogAction.java:45) at org.eclipse.ui.internal.handlers.ActionDelegateHandlerProxy.execute(ActionDelegateHandlerProxy.java:289) 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.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:471) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:822) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:880) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:569) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:511) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:126) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1184) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1002) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1040) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1036) at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1352) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3894) at org.eclipse.swt.widgets.Tree.WM_CHAR(Tree.java:5795) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3787) at org.eclipse.swt.widgets.Tree.windowProc(Tree.java:5791) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4541) at org.eclipse.swt.internal.win32.OS.$$YJP$$DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(OS.java) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2370) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3420) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) 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:382) 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:549) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504) at org.eclipse.equinox.launcher.Main.run(Main.java:1236) at org.eclipse.equinox.launcher.Main.main(Main.java:1212)

Files changed in fix:
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/activities/MutableActivityManager.java