Bug Null Pointer Exception if maximizing while being fought in pvp or receiving a kmail

If mafia is currently processing a maximize call, and you are either attacked in pvp or receive a kmail, it seems you get a null pointer exception. (May require you to currently have mafia chat open? Unsure)

I'm unsure if this is reproducible 100% of the time, but I do consistently run into this error under these conditions.

Here is the error from the debug log:


Code:
class java.lang.NullPointerException: Cannot invoke "java.lang.Comparable.compareTo(Object)" because "left" is null
java.lang.NullPointerException: Cannot invoke "java.lang.Comparable.compareTo(Object)" because "left" is null
    at net.java.dev.spellcast.utilities.SortedListModel.compare(SortedListModel.java:262)
    at net.java.dev.spellcast.utilities.SortedListModel.normalIndexOf(SortedListModel.java:175)
    at net.java.dev.spellcast.utilities.SortedListModel.indexOf(SortedListModel.java:132)
    at net.sourceforge.kolmafia.AdventureResult.getCount(AdventureResult.java:1109)
    at net.sourceforge.kolmafia.session.InventoryManager.getAccessibleCount(InventoryManager.java:202)
    at net.sourceforge.kolmafia.session.InventoryManager.getAccessibleCount(InventoryManager.java:173)
    at net.sourceforge.kolmafia.session.InventoryManager.getAccessibleCount(InventoryManager.java:169)
    at net.sourceforge.kolmafia.maximizer.CheckedItem.<init>(CheckedItem.java:27)
    at net.sourceforge.kolmafia.maximizer.Evaluator.enumerateEquipment(Evaluator.java:1205)
    at net.sourceforge.kolmafia.maximizer.Maximizer.maximize(Maximizer.java:158)
    at net.sourceforge.kolmafia.maximizer.Maximizer.maximize(Maximizer.java:102)
    at net.sourceforge.kolmafia.textui.RuntimeLibrary.maximize(RuntimeLibrary.java:7704)
    at net.sourceforge.kolmafia.textui.RuntimeLibrary.maximize(RuntimeLibrary.java:7684)
    at jdk.internal.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at net.sourceforge.kolmafia.textui.parsetree.LibraryFunction.execute(LibraryFunction.java:75)
    at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:113)
    at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:422)
    at net.sourceforge.kolmafia.textui.parsetree.Else.execute(Else.java:26)
    at net.sourceforge.kolmafia.textui.parsetree.If.execute(If.java:43)
    at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:422)
    at net.sourceforge.kolmafia.textui.parsetree.Conditional.execute(Conditional.java:54)
    at net.sourceforge.kolmafia.textui.parsetree.If.execute(If.java:35)
    at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:422)
    at net.sourceforge.kolmafia.textui.parsetree.Else.execute(Else.java:26)
    at net.sourceforge.kolmafia.textui.parsetree.If.execute(If.java:43)
    at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:422)
    at net.sourceforge.kolmafia.textui.parsetree.UserDefinedFunction.execute(UserDefinedFunction.java:87)
    at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:113)
    at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:422)
    at net.sourceforge.kolmafia.textui.parsetree.Loop.execute(Loop.java:23)
    at net.sourceforge.kolmafia.textui.parsetree.WhileLoop.execute(WhileLoop.java:55)
    at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:422)
    at net.sourceforge.kolmafia.textui.parsetree.UserDefinedFunction.execute(UserDefinedFunction.java:87)
    at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:113)
    at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:422)
    at net.sourceforge.kolmafia.textui.parsetree.UserDefinedFunction.execute(UserDefinedFunction.java:87)
    at net.sourceforge.kolmafia.textui.AshRuntime.executeScope(AshRuntime.java:258)
    at net.sourceforge.kolmafia.textui.AshRuntime.execute(AshRuntime.java:186)
    at net.sourceforge.kolmafia.textui.AshRuntime.execute(AshRuntime.java:179)
    at net.sourceforge.kolmafia.textui.command.CallScriptCommand.call(CallScriptCommand.java:194)
    at net.sourceforge.kolmafia.KoLmafiaCLI.doExecuteCommand(KoLmafiaCLI.java:477)
    at net.sourceforge.kolmafia.KoLmafiaCLI.executeCommand(KoLmafiaCLI.java:433)
    at net.sourceforge.kolmafia.KoLmafiaCLI.executeLine(KoLmafiaCLI.java:352)
    at net.sourceforge.kolmafia.KoLmafiaCLI.executeLine(KoLmafiaCLI.java:239)
    at net.sourceforge.kolmafia.swingui.CommandDisplayFrame$CommandQueueHandler.handleQueue(CommandDisplayFrame.java:139)
    at net.sourceforge.kolmafia.swingui.CommandDisplayFrame$CommandQueueHandler.run(CommandDisplayFrame.java:116)
 

MCroft

Developer
Staff member
hmm. Did you have items added or removed from your inventory while maximizing?
 

Ryo_Sangnoir

Developer
Staff member
In ChatManager.parseEvent, we update inventory after various events come in.

Locking inventory freezes the UI.

Perhaps we could have the maximizer copy the inventory as it is at the start of the process? Possibly it should do that anyway for e.g. things like familiar which can otherwise interfere with the result.
 
hmm. Did you have items added or removed from your inventory while maximizing?
During this crash specifically I had items added via kmail. But I've had a crash previously from a successful PVP defense, where no items were added or lost.
 
Just another example debug file, again coincided with getting attacked in pvp

Code:
Script execution aborted (java.lang.NullPointerException: Cannot invoke "java.lang.Comparable.compareTo(Object)" because "left" is null): (2crsfarm.ash, line 281)
Paolo Pinkel just attacked you!
 

Attachments

  • DEBUG_20230510.txt
    5.2 KB · Views: 1

MCroft

Developer
Staff member
Perhaps we could have the maximizer copy the inventory as it is at the start of the process? Possibly it should do that anyway for e.g. things like familiar which can otherwise interfere with the result.
Hmm. We need the most current inventory to actually do anything with the maximizer results. Maybe we should abort if the inventory changes.
 
Top