Bug Can't stop gash-jumping in preAscensionScript from JS (JS abort() and ASH abort() behave differently)

ziz

Member
I ran into an issue where I expected my JS preAscensionScript script to stop my jumping into the gash, because I called abort(), but it did not, in fact, prevent the gash-jumping.

(Using KoLmafia r27844 // Build main-3261eb6 17.0.10 (Eclipse Adoptium 17.0.10+7) Linux amd64 6.5.0-1015-azure)

The pre-ascension script call (defined here, called here) says (in the source) "If script aborts, we will not jump." If I'm reading the source correctly, JS scripts never "abort" - they either set the state to ERROR or to EXIT.

Here is a no-ascending-required demonstration, which I think is fairly comparable to the preAscensionScript failure, of how this produces different behavior between JS abort() and ASH abort() using trivial print-wait-abort scripts (attached). In both cases I ran the first cli commaand, The ASH version stops both the current command and queued commands, which I understand to be indicative of an ABORT state:

Code:
> test_abort.ash; print first post-abort print

Waiting for 5 seconds...
Countdown: 5 seconds...

>    CURRENT: test_abort.ash; print first post-abort print
>    QUEUED 1: print second post-abort print

Countdown: 4 seconds...
Countdown: 3 seconds...
Countdown: 2 seconds...
Countdown: 1 second...
Waiting completed.
Aborting...
This is a test of the abort function in ASH.

But the JS version only stops the current command, which suggests to me a state other than ABORT:

Code:
> test_abort.js; print first post-abort print

Waiting for 5 seconds...
Countdown: 5 seconds...

>    CURRENT: test_abort.js; print first post-abort print
>    QUEUED 1: print second post-abort print

Countdown: 4 seconds...
Countdown: 3 seconds...
Countdown: 2 seconds...
Countdown: 1 second...
Waiting completed.
Aborting...
This is a test of the abort function in JS.
JavaScript exception: KoLmafia error: This is a test of the abort function in JS.
at file:/Users/seposLibrary/Application%20Support/KoLmafia/scripts/test_abort.js:7    (main)

> print second post-abort print

second post-abort print

Obviously I can work around this with an ASH wrapper to my JS pre-ascension script, but it seems like consistent abort behavior would be beneficial and desirable.
 

Attachments

  • test_abort.ash
    160 bytes · Views: 1
  • test_abort.js
    261 bytes · Views: 1

Obeliks

Member
I believe the culprit is the `forceContinue()` call in JavascriptRuntime's checkInterrupted. This gets called after every AshStub (aka RuntimeLibrary function) invocation, including `abort`.

It made it's way into the code in this change: cb6c048 (note that forceContinue was not called before).

And then got slightly moved around here: 689bced

The commits don't give much reasoning as to why the error state should be reset here. I believe the line can either be removed completely, or we could throw a new JavascriptAbortException that is later used in to re-set the error set to Abort before exiting the top-level script.

@gausie, do you have any recollection why this was needed?
 
Last edited:
  • Like
Reactions: ziz
Top