Bug NPE caused by JS script

MCroft

Developer
Staff member
I'm assuming this is coming from excavator.js, but as @gausie says, an error in a script shouldn't cause an NPE. There's not much to go on here, but I wanted to get it recorded while I try to further debug.

Rich (BB code):
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
            KoLmafia r28001-M, Mac OS X, Java 18.0.2.1
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Timestamp: Sat Jul 20 00:38:00 CDT 2024
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 User: Mad Carew
 Current run: 828
 MRU Script: Unknown
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Unexpected error, debug log printed.
class java.lang.NullPointerException: Cannot invoke "org.mozilla.javascript.Scriptable.getParentScope()" because "obj" is null
java.lang.NullPointerException: Cannot invoke "org.mozilla.javascript.Scriptable.getParentScope()" because "obj" is null
    at org.mozilla.javascript.ScriptableObject.getTopLevelScope(ScriptableObject.java:1955)
    at org.mozilla.javascript.ScriptRuntime.setBuiltinProtoAndParent(ScriptRuntime.java:4400)
    at org.mozilla.javascript.Context.newObject(Context.java:1528)
    at net.sourceforge.kolmafia.textui.javascript.JavascriptRuntime.lambda$executeRun$4(JavascriptRuntime.java:370)
    at net.sourceforge.kolmafia.textui.javascript.JavascriptRuntime.executeFunction(JavascriptRuntime.java:255)
    at net.sourceforge.kolmafia.textui.javascript.JavascriptRuntime.executeRun(JavascriptRuntime.java:347)
    at net.sourceforge.kolmafia.textui.javascript.JavascriptRuntime.lambda$execute$1(JavascriptRuntime.java:233)
    at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:383)
    at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3940)
    at net.sourceforge.kolmafia.textui.javascript.JavascriptRuntime.execute(JavascriptRuntime.java:232)
    at net.sourceforge.kolmafia.textui.AbstractRuntime.execute(AbstractRuntime.java:24)
    at net.sourceforge.kolmafia.session.SpadingManager.invokeSpadingScript(SpadingManager.java:144)
    at net.sourceforge.kolmafia.session.SpadingManager.processCombatRound(SpadingManager.java:62)
    at net.sourceforge.kolmafia.request.FightRequest.updateCombatData(FightRequest.java:2578)
    at net.sourceforge.kolmafia.request.FightRequest.processResults(FightRequest.java:1813)
    at net.sourceforge.kolmafia.request.GenericRequest.parseResults(GenericRequest.java:2394)
    at net.sourceforge.kolmafia.request.GenericRequest.processResponse(GenericRequest.java:2225)
    at net.sourceforge.kolmafia.request.GenericRequest.retrieveServerReply(GenericRequest.java:2146)
    at net.sourceforge.kolmafia.request.GenericRequest.retrieveServerReply(GenericRequest.java:1738)
    at net.sourceforge.kolmafia.request.GenericRequest.externalExecute(GenericRequest.java:1400)
    at net.sourceforge.kolmafia.request.GenericRequest.execute(GenericRequest.java:1387)
    at net.sourceforge.kolmafia.request.GenericRequest.run(GenericRequest.java:1153)
    at net.sourceforge.kolmafia.request.RelayRequest.run(RelayRequest.java:3838)
    at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:242)
    at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:207)
    at net.sourceforge.kolmafia.webui.RelayAgent.readServerResponse(RelayAgent.java:436)
    at net.sourceforge.kolmafia.webui.RelayAgent.performRelay(RelayAgent.java:104)
    at net.sourceforge.kolmafia.webui.RelayAgent.run(RelayAgent.java:83)
 
I've hit this error during the Tunnel of LOV recently, after I started using a choiceAdventureScript. It happens as I move from the LOV combats to the subsequent choice adventures (which are handled by prefs, and not by the choiceAdventureScript). Seem to have gotten it as early as the 19th, so it can't be the most recent PR to mafia. And excavator hasn't been updated in about a month.
 
Hmmmmm. I wonder what is going on.
 
I wasn't running the darts, but that's what my choice adventure script was designed for.

Croft, what exactly were you doing when you hit the debug? Was it in response to the chained choice after the combat?

For what it's worth, a more full detailed explanation of my issue is:
- I run a script, which adventures in the Tunnel of LOV using adv1. I've set a bunch of choice adventure properties, and I also have an autoattack
- Things advance fine until I hit (and, thanks to autoattack, immediately resolve) the first combat. At this point, things stall indefinitely
- I open the relay browser, which causes a debug log to print. It opens to the choice after the first fight, which I manually resolve
- Things progress until the next combat, which behaves the same--instantly resolved via autoattack, followed by an indefinite stalling
- I either re-open the relay or navigate somewhere in the relay, ending up at the choice again and causing another debug log to print.

My debug logs also bring up the spadingScript in their debug chain, and also open with that same classic
Unexpected error, debug log printed.
class java.lang.NullPointerException: Cannot invoke "org.mozilla.javascript.Scriptable.getParentScope()" because "obj" is null
I'm going to revert to a version of my script that doesn't use a choiceAdventureScript to make sure that that's the issue
 
Last edited:
Still hunting it down. It wasn’t a blocking error, and the context was sparse, so I’m trying to re-run it with debugging on.
 
Had a quick look at this, the choice adventure is run in an infinite loop. Visiting the relay browser triggers the NPE (in the JavascriptRuntime??) somehow but only if you have a relayScript that calls visit_url() in some way, even if that relayScript is ASH. Really weird bug.
 
Back
Top