Bug java.lang.IndexOutOfBoundsException

Boesbert

Member
I kept getting "Unexpected error, debug log printed" messages in the GCLI. One after each outfit change through either relay browser chat or relay browser inventory interface or Gear Changer (Gear Changer being the only one which does not actually go through), two after each familiar change, and two after each turn I spent (manual or automated).

I am not aware of any special things I did differently than usual when this started happening. Using Chromium Version 55.0.2883.87 Built on Ubuntu , running on Ubuntu 16.04 (64-bit).

Mafia r17610

After I logged out of mafia and back in, the problem had stopped. I was not able to reproduce it. I still think I should mention it, just in case.

View attachment DEBUG_20161231.txt
 

Veracity

Developer
Staff member
Code:
class java.lang.IndexOutOfBoundsException: bitIndex < 0: -2147483648
java.lang.IndexOutOfBoundsException: bitIndex < 0: -2147483648
	at java.util.BitSet.get(BitSet.java:623)
	at javax.swing.DefaultListSelectionModel.clear(DefaultListSelectionModel.java:293)
	at javax.swing.DefaultListSelectionModel.setState(DefaultListSelectionModel.java:584)
	at javax.swing.DefaultListSelectionModel.insertIndexInterval(DefaultListSelectionModel.java:617)
	at javax.swing.plaf.basic.BasicListUI$Handler.intervalAdded(BasicListUI.java:2581)
	at javax.swing.AbstractListModel.fireIntervalAdded(AbstractListModel.java:148)
	at javax.swing.DefaultComboBoxModel.addElement(DefaultComboBoxModel.java:129)
	at javax.swing.JComboBox.addItem(JComboBox.java:716)
	at net.sourceforge.kolmafia.swingui.widget.DisabledItemsComboBox.addItem(DisabledItemsComboBox.java:65)
	at net.sourceforge.kolmafia.swingui.panel.DailyDeedsPanel$HatterDaily.update(DailyDeedsPanel.java:3950)
	at net.sourceforge.kolmafia.listener.ListenerRegistry.fireListeners(ListenerRegistry.java:269)
	at net.sourceforge.kolmafia.listener.ListenerRegistry.deferListeners(ListenerRegistry.java:108)
	at net.sourceforge.kolmafia.listener.PreferenceListenerRegistry.deferPreferenceListeners(PreferenceListenerRegistry.java:44)
	at net.sourceforge.kolmafia.request.GenericRequest.retrieveServerReply(GenericRequest.java:2469)
	at net.sourceforge.kolmafia.request.GenericRequest.retrieveServerReply(GenericRequest.java:2057)
	at net.sourceforge.kolmafia.request.GenericRequest.externalExecute(GenericRequest.java:1617)
	at net.sourceforge.kolmafia.request.GenericRequest.execute(GenericRequest.java:1600)
	at net.sourceforge.kolmafia.request.GenericRequest.run(GenericRequest.java:1320)
	at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:286)
	at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:249)
	at net.sourceforge.kolmafia.session.MonsterManuelManager.getFactoidsAvailable(MonsterManuelManager.java:451)
	at net.sourceforge.kolmafia.textui.RuntimeLibrary.monster_factoids_available(RuntimeLibrary.java:7324)
Something is triggering the "Hatter" Daily Deed to update itself. An outfit change could do that, I guess, since it changes hats.
If that causes an exception, the setting that triggered the listener would still remain armed, I expect.

We are updating the GUI outside of the Swing thread.
We are not trapping exceptions from listeners and counting them as finished (we don't expect exceptions, after all).
The Hatter daily deed is especially tricky. It is perhaps the only user of a "DisabledItemComboBox" widget.

I got a stack trace yesterday in the Hatter Daily Deed:

Code:
class java.lang.ArrayIndexOutOfBoundsException: 0
java.lang.ArrayIndexOutOfBoundsException: 0
	at javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1368)
	at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:1311)
	at javax.swing.plaf.basic.BasicListUI$Handler.valueChanged(BasicListUI.java:2623)
	at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:184)
	at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:164)
	at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:211)
	at javax.swing.DefaultListSelectionModel.insertIndexInterval(DefaultListSelectionModel.java:632)
	at javax.swing.plaf.basic.BasicListUI$Handler.intervalAdded(BasicListUI.java:2581)
	at javax.swing.AbstractListModel.fireIntervalAdded(AbstractListModel.java:148)
	at javax.swing.DefaultComboBoxModel.addElement(DefaultComboBoxModel.java:129)
	at javax.swing.JComboBox.addItem(JComboBox.java:716)
	at net.sourceforge.kolmafia.swingui.panel.DailyDeedsPanel$HatterDaily.update(DailyDeedsPanel.java:3915)
	at net.sourceforge.kolmafia.listener.ListenerRegistry.fireListeners(ListenerRegistry.java:269)
	at net.sourceforge.kolmafia.listener.ListenerRegistry.fireListener(ListenerRegistry.java:168)
	at net.sourceforge.kolmafia.listener.PreferenceListenerRegistry.firePreferenceChanged(PreferenceListenerRegistry.java:54)
	at net.sourceforge.kolmafia.KoLCharacter.updateStatus(KoLCharacter.java:5461)
	at net.sourceforge.kolmafia.KoLCharacter.updateSelectedLocation(KoLCharacter.java:5469)
	at net.sourceforge.kolmafia.swingui.panel.ChoiceOptionsPanel$UpdateChoicesListener.valueChanged(ChoiceOptionsPanel.java:848)
	at javax.swing.JList.fireSelectionValueChanged(JList.java:1796)
	at javax.swing.JList$ListSelectionHandler.valueChanged(JList.java:1810)
	at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:184)
	at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:164)
	at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:211)
	at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:405)
	at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:415)
	at javax.swing.DefaultListSelectionModel.setSelectionInterval(DefaultListSelectionModel.java:459)
	at javax.swing.JList.setSelectedIndex(JList.java:2210)
	at javax.swing.JList.setSelectedValue(JList.java:2360)
	at net.sourceforge.kolmafia.swingui.panel.AdventureSelectPanel.updateSelectedAdventure(AdventureSelectPanel.java:269)
	at net.sourceforge.kolmafia.swingui.AdventureFrame.updateSelectedAdventure(AdventureFrame.java:168)
	at net.sourceforge.kolmafia.swingui.AdventureFrame.<init>(AdventureFrame.java:100)
This was creating the AdventureFrame. It was in the Swing Thread.

This all makes me want to look closely at the Hatter Daily Deed.
 

Veracity

Developer
Staff member
Revision 17708 changes the Hatter Daily Deed quite a bit. It no longer discards and reallocates a couple of lists every time it updates. Instead, it updates them in place. Since they are both synchronized lists, that mean that multiple threads really should be blocked out of updating them, rather than each updating a list, only one of which will actually end up retained.

It should only be done in the Swing thread, anyway, which would make that moot.

Pondering.
 
Top