Bug - Fixed Getting NPE when trying to run "AdventureAdvisor"

I tried using AdventureAdvisor today, and started getting NPEs. Here's the relevant snippit of the debug log, I can post the whole thing if it helps but it's pretty large (7.5 megs uncompressed). I started digging at the code, and got lazy since I haven't dealt much with the scripting engine or what the "to_url" function does, figured I'd let the experts know. This is with latest kolmafia (r11498), and latest adventureadvisor (2.7.8, although it was happening with 2.7.7 as well, I upgraded on the off chance it was part of the problem). I'm doing a SC ZC run, and (presumably relevant), I've got the muscle sign for degrassi knoll.

Code:
                                                         Eval: link()
                                                            Param #1: loc_to_url()
                                                               Param #1: w
                                                               [NORMAL] <- "Degrassi Knoll"
                                                               Entering function loc_to_url
                                                                     switch
                                                                     Value: where
                                                                     [NORMAL] <- Degrassi Knoll
                                                                  [NORMAL] <- void
                                                                     if
                                                                     Test: ( kingdom[] == "" )
                                                                        Operator: ==
                                                                           Operand 1: kingdom[]
                                                                              AREF: aggregate place [string]
                                                                                 Key #1: where
                                                                                 [NORMAL] <- "Degrassi Knoll"
                                                                              AREF <- record place
                                                                                 Key #2: "locphp"
                                                                                 [NORMAL] <- "locphp"
                                                                              AREF <- ""
                                                                           [NORMAL] <- ""
                                                                           Operand 2: 
                                                                           [NORMAL] <- ""
                                                                        <- true
                                                                     [NORMAL] <- true
                                                                           Eval: to_url()
                                                                              Param #1: kingdom[]
                                                                                 AREF: aggregate place [string]
                                                                                    Key #1: where
                                                                                    [NORMAL] <- "Degrassi Knoll"
                                                                                 AREF <- record place
                                                                                    Key #2: "loc"
                                                                                    [NORMAL] <- "loc"
                                                                                 AREF <- "none"
                                                                              [NORMAL] <- "none"
                                                                              Entering function to_url
Unexpected error, debug log printed.
class java.lang.NullPointerException: null
java.lang.NullPointerException
	at net.sourceforge.kolmafia.textui.RuntimeLibrary.to_url(RuntimeLibrary.java:2144)
	at sun.reflect.GeneratedMethodAccessor69.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at net.sourceforge.kolmafia.textui.parsetree.LibraryFunction.execute(LibraryFunction.java:115)
	at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:169)
	at net.sourceforge.kolmafia.textui.parsetree.FunctionReturn.execute(FunctionReturn.java:100)
	at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:465)
	at net.sourceforge.kolmafia.textui.parsetree.Conditional.execute(Conditional.java:96)
	at net.sourceforge.kolmafia.textui.parsetree.If.execute(If.java:68)
	at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:465)
	at net.sourceforge.kolmafia.textui.parsetree.UserDefinedFunction.execute(UserDefinedFunction.java:139)
	at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:169)
	at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:107)
	at net.sourceforge.kolmafia.textui.parsetree.FunctionReturn.execute(FunctionReturn.java:100)
	at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:465)
	at net.sourceforge.kolmafia.textui.parsetree.UserDefinedFunction.execute(UserDefinedFunction.java:139)
	at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:169)
	at net.sourceforge.kolmafia.textui.parsetree.Operator.applyTo(Operator.java:606)
	at net.sourceforge.kolmafia.textui.parsetree.Expression.execute(Expression.java:223)
	at net.sourceforge.kolmafia.textui.parsetree.Operator.applyTo(Operator.java:406)
	at net.sourceforge.kolmafia.textui.parsetree.Expression.execute(Expression.java:223)
	at net.sourceforge.kolmafia.textui.parsetree.Operator.applyTo(Operator.java:406)
	at net.sourceforge.kolmafia.textui.parsetree.Expression.execute(Expression.java:223)
	at net.sourceforge.kolmafia.textui.parsetree.Operator.applyTo(Operator.java:406)
	at net.sourceforge.kolmafia.textui.parsetree.Expression.execute(Expression.java:223)
	at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:107)
	at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:465)
	at net.sourceforge.kolmafia.textui.parsetree.UserDefinedFunction.execute(UserDefinedFunction.java:139)
	at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:169)
	at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:465)
	at net.sourceforge.kolmafia.textui.parsetree.Loop.execute(Loop.java:59)
	at net.sourceforge.kolmafia.textui.parsetree.ForEachLoop.executeSlice(ForEachLoop.java:166)
	at net.sourceforge.kolmafia.textui.parsetree.ForEachLoop.execute(ForEachLoop.java:111)
	at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:465)
	at net.sourceforge.kolmafia.textui.parsetree.UserDefinedFunction.execute(UserDefinedFunction.java:139)
	at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:169)
	at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:465)
	at net.sourceforge.kolmafia.textui.parsetree.UserDefinedFunction.execute(UserDefinedFunction.java:139)
	at net.sourceforge.kolmafia.textui.Interpreter.executeScope(Interpreter.java:369)
	at net.sourceforge.kolmafia.textui.Interpreter.execute(Interpreter.java:296)
	at net.sourceforge.kolmafia.textui.Interpreter.execute(Interpreter.java:289)
	at net.sourceforge.kolmafia.KoLmafiaASH.getClientHTML(KoLmafiaASH.java:108)
	at net.sourceforge.kolmafia.KoLmafiaASH.getClientHTML(KoLmafiaASH.java:75)
	at net.sourceforge.kolmafia.request.RelayRequest.handleSimple(RelayRequest.java:1740)
	at net.sourceforge.kolmafia.request.RelayRequest.run(RelayRequest.java:1769)
	at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:222)
	at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:185)
	at net.sourceforge.kolmafia.webui.RelayAgent.readServerResponse(RelayAgent.java:519)
	at net.sourceforge.kolmafia.webui.RelayAgent.performRelay(RelayAgent.java:158)
	at net.sourceforge.kolmafia.webui.RelayAgent.run(RelayAgent.java:131)

Script execution aborted
 

Catch-22

Active member
The problem can be condensed to:
ash to_url($location[none])

The problem being that "none" is a built-in location in KoLmafia (for some reason) but (I'm guessing) has no associated URL. I'll take a look.

Edit: This patches to_url to return a zero-length string when it is called against a non-existent adventure (such as "none"). Not really sure if it's all that should be fixed though, I don't know why we allow $locaton[none] in the first place.
 

Attachments

  • to_url.patch
    585 bytes · Views: 43
Last edited:
I'll tell you if that fixed it in a few minutes when we're out of maintenance. Or at least, stopped the NPE.

fwiw, here's a "normal" call to to_url, from earlier in the same debug log:

Code:
                                                                    [NORMAL] <- true
                                                                           Eval: to_url()
                                                                              Param #1: kingdom[]
                                                                                 AREF: aggregate place [string]
                                                                                    Key #1: where
                                                                                    [NORMAL] <- "Bugbear Waste Processing"
                                                                                 AREF <- record place
                                                                                    Key #2: "loc"
                                                                                    [NORMAL] <- "loc"
                                                                                 AREF <- "Waste Processing"
                                                                              [NORMAL] <- "Waste Processing"
                                                                              Entering function to_url
                                                                              Function to_url returned: adventure.php?snarfblat=282
                                                                           Returning: adventure.php?snarfblat=282
                                                                        [RETURN] <- "adventure.php?snarfblat=282"
                                                                  [RETURN] <- "adventure.php?snarfblat=282"
                                                               Function loc_to_url returned: adventure.php?snarfblat=282

in my case, degrassi knoll isn't adventurable, but not sure why that's triggering the issue.
 
So, that "fixed" the issue, in that AdventureAdvisor now runs without error. Interestingly, the degrassi knoll listing that seemed to trigger the error is wrong, in that instead of linking to knoll.php, it's linking to http://127.0.0.1:60080/relay_AdventureAdvisor.ash - presumably as a side effect of passing back the empty string. so something else underlying in the system is wrong.
 

Theraze

Active member
I don't know why we allow $locaton[none] in the first place.

Among other things, fighting monsters through objects sets your location to none, so that it doesn't believe you can use underwater skills when KoL doesn't think you're underwater...
 

Catch-22

Active member
Among other things, fighting monsters through objects sets your location to none, so that it doesn't believe you can use underwater skills when KoL doesn't think you're underwater...

Thanks, it seemed somewhat purposeful, so I figured there was a reason :)

So something else underlying in the system is wrong.

It's also possible that there are bugs in AdventureAdvisor and KoLmafia is just doing what it's told.
 
Top