Bug 109011 - [KeyBindings] AIOOBE on startup
Summary: [KeyBindings] AIOOBE on startup
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P1 blocker (vote)
Target Milestone: 3.1.1   Edit
Assignee: Douglas Pollock CLA Friend
QA Contact:
URL:
Whiteboard:
Keywords:
: 109707 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-09-07 19:11 EDT by Andre Weinand CLA Friend
Modified: 2005-09-22 10:51 EDT (History)
3 users (show)

See Also:


Attachments
BindingManager.patch (610 bytes, patch)
2005-09-09 12:48 EDT, Susan McCourt CLA Friend
no flags Details | Diff
compressed org.eclipse.ui.workbench.prefs (1.23 KB, application/octet-stream)
2005-09-09 12:53 EDT, Andre Weinand CLA Friend
no flags Details
patch for BindingManager.java (1.46 KB, patch)
2005-09-09 18:38 EDT, Andre Weinand CLA Friend
no flags Details | Diff
Patch to BindingManager (alternate) (540 bytes, patch)
2005-09-21 12:03 EDT, Douglas Pollock CLA Friend
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andre Weinand CLA Friend 2005-09-07 19:11:20 EDT
I20050906 + ZRH HEAD + JFace HEAD

The following exception kills Eclipse on startup (with existing or fresh workspace):

!SESSION 2005-09-08 01:10:07.947 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.4.2_09
java.vendor=Apple Computer, Inc.
BootLoader constants: OS=macosx, ARCH=ppc, WS=carbon, NL=en_US
Framework arguments:  -application org.eclipse.ui.ide.workbench -pdelaunch
Command-line arguments:  -application org.eclipse.ui.ide.workbench -data /Volumes/Stuff/Eclipse/
test_ws/enc16 -dev file:/Users/weinand/Eclipse/workspaces/release/.metadata/.plugins/
org.eclipse.pde.core/enc16/dev.properties -pdelaunch -consoleLog -os macosx -ws carbon -arch ppc

!ENTRY org.eclipse.ui 4 4 2005-09-08 01:10:14.584
!MESSAGE Unhandled event loop exception

!ENTRY org.eclipse.ui 4 0 2005-09-08 01:10:14.589
!MESSAGE 261
!STACK 0
java.lang.ArrayIndexOutOfBoundsException: 261
	at org.eclipse.jface.bindings.BindingManager.removeDeletions(BindingManager.java:1649)
	at org.eclipse.jface.bindings.BindingManager.computeBindings(BindingManager.java:491)
	at org.eclipse.jface.bindings.BindingManager.recomputeBindings(BindingManager.java:1466)
	at org.eclipse.jface.bindings.BindingManager.getActiveBindingsByParameterizedCommand
(BindingManager.java:825)
	at org.eclipse.jface.bindings.BindingManager.getActiveBindingsFor(BindingManager.java:1071)
	at org.eclipse.ui.internal.keys.BindingService.getActiveBindingsFor(BindingService.java:91)
	at org.eclipse.ui.internal.ide.actions.QuickMenuAction.getShortCutString(QuickMenuAction.java:
108)
	at org.eclipse.ui.internal.ide.WorkbenchActionBuilder$6.getMenuText
(WorkbenchActionBuilder.java:457)
	at org.eclipse.jface.action.MenuManager.fill(MenuManager.java:221)
	at org.eclipse.jface.action.MenuManager.update(MenuManager.java:627)
	at org.eclipse.jface.action.MenuManager.update(MenuManager.java:549)
	at org.eclipse.jface.action.MenuManager.fill(MenuManager.java:232)
	at org.eclipse.jface.action.MenuManager.update(MenuManager.java:627)
	at org.eclipse.jface.action.MenuManager.update(MenuManager.java:549)
	at org.eclipse.jface.action.MenuManager.createMenuBar(MenuManager.java:158)
	at org.eclipse.jface.action.MenuManager.createMenuBar(MenuManager.java:174)
	at org.eclipse.ui.internal.WorkbenchWindow.createDefaultContents(WorkbenchWindow.java:929)
	at org.eclipse.ui.internal.WorkbenchWindowConfigurer.createDefaultContents
(WorkbenchWindowConfigurer.java:577)
	at org.eclipse.ui.application.WorkbenchWindowAdvisor.createWindowContents
(WorkbenchWindowAdvisor.java:261)
	at org.eclipse.ui.internal.WorkbenchWindow.createContents(WorkbenchWindow.java:897)
	at org.eclipse.jface.window.Window.create(Window.java:418)
	at org.eclipse.ui.internal.Workbench.busyOpenWorkbenchWindow(Workbench.java:663)
	at org.eclipse.ui.internal.Workbench.doOpenFirstTimeWindow(Workbench.java:1317)
	at org.eclipse.ui.internal.Workbench.openFirstTimeWindow(Workbench.java:1223)
	at org.eclipse.ui.internal.WorkbenchConfigurer.openFirstTimeWindow(WorkbenchConfigurer.java:
190)
	at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:706)
	at org.eclipse.ui.internal.Workbench.init(Workbench.java:1034)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1671)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
	at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103)
	at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:377)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:164)
	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:324)
	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:338)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:282)
	at org.eclipse.core.launcher.Main.run(Main.java:977)
	at org.eclipse.core.launcher.Main.main(Main.java:952)
Comment 1 Kim Horne CLA Friend 2005-09-09 11:00:17 EDT
Shoot... and Doug is out of town.  Susan, could you take a peek at this?
Comment 2 Susan McCourt CLA Friend 2005-09-09 12:15:17 EDT
I'll look at this right now...
Comment 3 Susan McCourt CLA Friend 2005-09-09 12:42:08 EDT
Andre - I can't reproduce this one, but I don't have anything but default key 
bindings.  Could you attach your bindings?
I think everything I should need is in

<workspace>/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.u
i.workbench.prefs

I'm also going to attach an experimental patch, because in examining the code, 
I think I see the problem...


Comment 4 Susan McCourt CLA Friend 2005-09-09 12:48:09 EDT
Created attachment 26988 [details]
BindingManager.patch

Andre - could you give this a try?
This is a trial patch based on eyeballing the code.
This seems an obvious problem, but I'm surprised no one else has had the
exception.  I'm not sure what state the key bindings have to be in to trigger
the problem.
Comment 5 Andre Weinand CLA Friend 2005-09-09 12:53:06 EDT
Created attachment 26989 [details]
compressed org.eclipse.ui.workbench.prefs

Hi Susan, here is the requested file. However, I'm seeing the problem with a
fresh workspace too.
Comment 6 Andre Weinand CLA Friend 2005-09-09 13:05:15 EDT
Sorry, but the patch doesn't fix the problem for me.
Comment 7 Andre Weinand CLA Friend 2005-09-09 13:14:30 EDT
You are aware that the bug occured on the Mac?
Comment 8 Susan McCourt CLA Friend 2005-09-09 13:17:47 EDT
sigh...the patch was a no-op (pre-post increment confusion on my part).  
Sorry 'bout that.  I can't get this to obviously fail on Windows.  

Can you tell me what's loaded in your workspace (what is ZRH head?)
And is there any corresponding workbench HEAD loaded?...
Are your non-Mac counterparts seeing the problem with similar configs?



Comment 9 Susan McCourt CLA Friend 2005-09-09 13:29:24 EDT
Comment on attachment 26988 [details]
BindingManager.patch

(ignore this...blush)
Comment 10 Andre Weinand CLA Friend 2005-09-09 18:34:12 EDT
The calculation of "deletedCount" is wrong because null-valued slots of the "bindingsCopy" array are set 
to null (deleted) multiple times, thus counted as deleted more than once (line 1634).
Since the resulting array is shortened by the number of deleted slots, but the copying of slots is done if a 
slot is non-null, an AIOOBE must occur as soon as any deleted slot is counted twice.

The attached patch fixes this problem by not relying on the algorithm to maintain a correct 
"deletedCount". Instead the empty slots are counted before copying (and compacting) the array.
The fix ensures:
- that the array is in fact compacted,
- that no AIOOBE can occur,
- and that the new behavior of the algorithm is not worse than the original behavior.
Comment 11 Andre Weinand CLA Friend 2005-09-09 18:38:00 EDT
Created attachment 26996 [details]
patch for BindingManager.java
Comment 12 Kim Horne CLA Friend 2005-09-16 08:37:01 EDT
*** Bug 109707 has been marked as a duplicate of this bug. ***
Comment 13 Kim Horne CLA Friend 2005-09-16 08:37:29 EDT
Note that this flaw was also introduced into the 3.1.1 stream.
Comment 14 Susan McCourt CLA Friend 2005-09-19 18:04:10 EDT
Sorry, I meant to reassign this to Doug before I left town last week.  I'd 
rather he review the patch since he's been working in this code...
Comment 15 Douglas Pollock CLA Friend 2005-09-21 12:01:17 EDT
If I understand correctly, this happens because of a missing "break" statement  
after line 1634 of BindingManager.  Another approach is to perform a second 
iteration over the array to count the deletions (as given by Andre's patch).  
The AIOOBE can happen if two or more deletions markers for the same trigger 
sequence match an existing binding. 
 
Comment 16 Douglas Pollock CLA Friend 2005-09-21 12:03:29 EDT
Created attachment 27341 [details]
Patch to BindingManager (alternate)

Andre: does this patch work for you?  Do I understand the problem correctly?
Comment 17 Andre Weinand CLA Friend 2005-09-21 12:52:56 EDT
Yes, your patch fixes the problem for me.
Comment 18 Douglas Pollock CLA Friend 2005-09-21 15:34:23 EDT
Fixed in CVS.  Caused by the fix for Bug 106574.  Applying patch to 3.1.1  
maintenance stream as well. 
Comment 19 Douglas Pollock CLA Friend 2005-09-22 10:16:47 EDT
Andre: would you be able to confirm that the problem you see is fixed in 
I20050921-1600 or later? 
  
Comment 20 Andre Weinand CLA Friend 2005-09-22 10:21:13 EDT
will do...
Comment 21 Andre Weinand CLA Friend 2005-09-22 10:47:30 EDT
verified for I20050921-2000
Comment 22 Douglas Pollock CLA Friend 2005-09-22 10:51:39 EDT
Thank you very much.  I also cannot reproduce the problem anymore.  Marking as 
verified.