Bug - Fixed Stack overflow during ASH script

ckb

Minion
Staff member
Not sure how / why this happened, or exactly what did it. Reference other comments in ZLib thread here.

Debug log attached.
 

Attachments

  • DEBUG_20170609.txt
    88 KB · Views: 648

ckb

Minion
Staff member
What is your CCS?

That is harder to answer. I think my script was doing this:
adventure(1, bhloc, "NoseMon");

Code:
string NoseMon(int rnd, monster opp, string page) {
	if (have_effect($effect[On the Trail])==0 && (opp==bhmon1 || opp==bhmon2)) {
		return "skill Transcendent Olfaction";
	}
	return get_ccs_action(rnd);
}

And my CSS is:
Code:
[ angry viking warriors ]
"pickpocket"
skill spectral snapper

[ candied yam golem ]
"pickpocket"
skill lunging thrust-smack

[ cinco de mayo reveler ]
"pickpocket"
skill lunging thrust-smack

[ default ]
"pickpocket"
attack with weapon

[ endless winter ]
"pickpocket"
attack with weapon

[ malevolent tofurkey ]
"pickpocket"
skill lunging thrust-smack

[ novia cadaver ]
"pickpocket"
skill lunging thrust-smack

[ novio cadaver ]
"pickpocket"
skill lunging thrust-smack

[ padre cadaver ]
"pickpocket"
skill lunging thrust-smack

[ persona inocente cadaver ]
"pickpocket"
skill lunging thrust-smack

[ possessed can of cranberry sauce ]
"pickpocket"
skill lunging thrust-smack

[ stuffing golem ]
"pickpocket"
skill lunging thrust-smack

[ tres de mayo reveler ]
"pickpocket"
skill lunging thrust-smack
 

Veracity

Developer
Staff member
Yeah. This is fallout from the change that I made that submits the "ireallymeantit" redirect by itself - which means that what used to be round 0 is now round 1.

I'll think about it more, now that it is (will be) the weekend.

Issues:

- If you have autoattack, you really don't ever get "round 0".
- get_ccs_action( round ) only ever worked if you had pure KoLmafia actions - including, perhaps, single-line BALLS actions. Considering that you can have arbitrary BALLS stuff in there spanning multiple lines, what use is it to fetch the 3rd line, say, because it is round 3 - but a whole bunch of lines were taken up by BALLS conditionals and such?

I wonder if it was trying to "pickpocket", but decided it couldn't, and just looped.

I should be able to test this; I have 3 characters who can pickpocket.
 

Veracity

Developer
Staff member
Hmm. You had insufficient MP to cast Olfaction and did not have "autoManaRestore" set.

1) KoLmafia calls your filter to get the next action
2) Your filter returns "skill Transcendent Olfaction" (ignoring "current round")
3) KoLmafia notices that you can't afford to cast it and increments the "current round" in your CCS
4) KoLmafia calls your filter to get the next action
5) Your filter returns "skill Transcendent Olfaction" (ignoring "current round")
6) goto 3

I take back my previous comment that this had something to do with my previous change.

We have code to deal with a "consult script that does nothing".
Presumably we need code to deal with a "combat filter that does nothing".

There may be an existing bug report for this. If not, this will serve to track the issue.
 

Veracity

Developer
Staff member
Revision 18097 will cause an abort if a combat filter returns a rejected action, is called again in the same round, and returns the same action. When I was initially learning about combat filters for VMF, I had this same sort of bug in my filter and caused infinite recursion, just like we saw here. That's why I could swear I posted about that, somewhere. If it was a bug report, I'll track it down and close it.

I suppose the combat filter could cycle through multiple invalid actions without ever returning something sensible. This revision will not guard against that.

Don't do that.
 

ckb

Minion
Staff member
Thanks Veracity.
Does the script just abort, or does it abort with some special "your combat action returned a rejected action" message?

Also, I will now try to avoid such things more heartily in the future.
 

Veracity

Developer
Staff member
It behaves as if the combat filter returns "abort" as the action.

Huh. It would be nice if you could put "abort MSG" into your CCS, but you can't.
That would be a (non-trivial) Feature Request; I see all sorts of places in FightRequest where is simply checks if the action equals "abort".
 
I have no idea how or why, but this script broke my automation.

To be exact, it's my free fights.ash script that breaks, for some reason, run_combat() (called right after finishing a combat, while eldritch attunement is active), now gets into the fight against the tentacle without my autoattack firing. It then loops endlessly executing my empty CCS macro. That second part makes sense, at least that's what it always did (which doesn't seem right, but it works for me, so eh...), but I don't understand how it managed to get into the fight without my autoattack firing (which is a BALLS macro which would kill it just fine, which is the reason my CCS is empty).

(for reference, the CCS isn't actually empty, because mafia doesn't like that so it's "[default] abort")
 
Last edited:

Veracity

Developer
Staff member
I also don't know what "this script" is or what calling run_combat "right after finishing a combat" is supposed to do.

Let's see a DEBUG log, please. I want to see all the requests and responses surrounding and including what you are finding wrong.
 
Code:
		while(set_snojo()) {
			if (chooseFamiliar() != my_familiar()) use_familiar(chooseFamiliar());
			adv1($location[The X-32-F Combat Training Snowman], -1, "");
			if (have_effect($effect[Eldritch Attunement])>0)
				run_combat();
		}

Thats the representative part of the script I use. Calling run_combat() after finishing the (free) fight used to work very nicely to clear out the eldritch tentacle spawned by having eldritch attunement active, but that fight currently doesn't resolve because my autoattack gets skipped over.

As for the debug log, I used debug on, fought a fight against a snowman, had it fail as expected, clicked the main map icon in the relay browser to get that to load the fight, and manually called the macro that's supposed to be called at autoattack to finish the fight. (and then debug off).

Edit: I don't know if it's related, but currently the cli and my session logs have the line "Round 0: the dictator executes a macro!" printed after a combat gets finished succesfully finished by my autoattack, which is definitely new.
 

Attachments

  • DEBUG_20170611.txt
    569.1 KB · Views: 283
Last edited:

Veracity

Developer
Staff member
Code:
Requesting: https://www.kingdomofloathing.com/adventure.php?snarfblat=460
Retrieved: https://www.kingdomofloathing.com/adventure.php?snarfblat=460
Field: Location = [fight.php?ireallymeanit=1497158621]
Requesting: https://www.kingdomofloathing.com/fight.php?ireallymeanit=1497158621
Retrieved: https://www.kingdomofloathing.com/fight.php?ireallymeanit=1497158621
ResponseText has 83820 characters.

[17242] The X-32-F Combat Training Snowman
Encounter: the X-32-F Combat Training Snowman
Round 0: the dictator wins initiative!
Round 0: the dictator tries to steal an item!
---
Round 18: the dictator wins the fight!
Apparently, your autoattack was a lengthy macro.

Code:
<a name="end"></a><a href="fight.php" id="againlink">The barrier between world is torn...</a>
Oh. There is a link to fight.php at the end. This is a multifight.

Code:
class net.sourceforge.kolmafia.request.FightRequest
Round 0: the dictator executes a macro!
Requesting: https://www.kingdomofloathing.com/fight.php?action=macro&macrotext=%0A%0A%0Amark+mafiafinal%0Aabort+%22KoLmafia+CCS+abort%22%0Agoto+mafiafinal
Retrieved: https://www.kingdomofloathing.com/fight.php?action=macro&macrotext=%0A%0A%0Amark+mafiafinal%0Aabort+%22KoLmafia+CCS+abort%22%0Agoto+mafiafinal

Encounter: Eldritch Tentacle named Blllrrggghggggrrgglbrghbrghshhhhh
Strategy: D:\Games\Kingdom of Loathing\KoLMafia\ccs\default.ccs [default]
Round 0: the dictator wins initiative!

class net.sourceforge.kolmafia.request.FightRequest
Round 1: the dictator executes a macro!
Requesting: https://www.kingdomofloathing.com/fight.php?action=macro&macrotext=%0A%0A%0Amark+mafiafinal%0Aabort+%22KoLmafia+CCS+abort%22%0Agoto+mafiafinal
Retrieved: https://www.kingdomofloathing.com/fight.php?action=macro&macrotext=%0A%0A%0Amark+mafiafinal%0Aabort+%22KoLmafia+CCS+abort%22%0Agoto+mafiafinal
So, in the browser, you'd finish your Snojo fight, KoLmafia would say "The barrier between world[sic] is torn", you click it to get fight.php - which (I assume) would redirect to fight.php?ireallymeantit=xxx and when THAT is followed, KoL does its usual "load up the initial round, run autoattack, etc." stuff.

Here, you are in a multifight at round zero and we submit your macrofied CCS.

I did remove some code which tried to "macrofy round zero" since I couldn't see how you'd ever get the opportunity to submit a macro with round zero.

Apparently we are not playing nicely with automating multi-fights any more; the do not automatically redirect through "ireallymeantit".

I'll consider this.

And next time I will request turning off Guide before getting a log; it makes the log many times larger and the sequence of requests a lot harder to extract. :)
 
Thanks for looking into this. I can't test this today, as I already ran out of free fights and eldritch attunement, but I'll see what happens tomorrow.
Edit: Oh, and sorry about the Guide thing, I didn't even realize that was the reason why it was so lengthy, or I would have fought another snowmen ;)
 
Last edited:

xKiv

Active member
Edit: I don't know if it's related, but currently the cli and my session logs have the line "Round 0: the dictator executes a macro!" printed after a combat gets finished succesfully finished by my autoattack, which is definitely new.

I have also noticed this, except for me it's wham/smartstasis printing their own messages about finishing the fight already. Example from session log (the entire fight is won by autoattack macro, skipping to end):

Code:
Round 10: xKiv wins the fight!
After Battle: A love deathwatch beetle creeps toward you, rolling a spooky coin.
You acquire an item: Freddy Kruegerand
After Battle: Jamlord bumps into some extra stuff with the snow suit's carrot nose, and shares what he finds with you.
After Battle: You gain 9 Mojo Points
After Battle: DNÉPPSÏ spotlights your opponent's pockets for you.
After Battle: Jamlord finds a leek somewhere and sings a polka while twirling it around.
After Battle: The grateful Dreadsylvanian blacksmith gives you a kiss on the cheek. Must be some kind of adorable foreign custom.
You acquire an item: BACON (5)
After Battle: You gain 24 Beefiness
You gain a Muscle point!
After Battle: You gain 40 Wizardliness
You gain a Mysticality point!
After Battle: You gain 60 Smarm
You gain a Moxie point!
> WHAM: Running SmartStasis
> WHAM: SS has finished the fight. Aborting script execution.

It's like mafia is now trying to run the ccs (which in my case is just "consult WHAM") no matter what, even though the fight is already over?
 
On revision 18102, it still doesn't work, but now for different reasons: calling run_combat after finishing the first fight simply seems to do nothing at all. The second fight never gets started, and my script chokes on whatever it's trying to do afterwards. (claiming a redirect to a fight page in the cli, but not actually reporting anything from the new fight, though calling visit_url("main.php") does succesfully load the second fight).

Edit: Cheesecookie suggested using adv1() instead, and replacing the "run_combat()" I was using to clear the tentacle with "adv1($location[An Overgrown Shrine (Northwest)] ,-1,"");" does indeed work to restore the old functionality, and has the added bonus of confusing mafia and my sessions logs, because it now thinks all the tentacle fights are happening in one very eldritch, overgrown shrine-portal.
 
Last edited:

Veracity

Developer
Staff member
I'll have another chance to work on this on Saturday.
I no longer have time to work on KoLmafia during the week.
 
Well, with the above workaround in my scripts, I no longer care too much. Having a look and restoring the old functionality could be handy for other people though.
 
Top