I finally got the bug to trigger (40.23). Stationed inside a locked door, paused, unlocked the door, issued the kill order, unpaused, got the bug and everyone standing around like idiots. Told them to station again, they wake up and kill folks, or enough of them to get the job done. Going directly to kill works fine. Station works fine. Telling folk to kill when they're on station is dodgy.
I'm setting up a bunch of cage traps to get some on-queue fights set up to see if I can reliably trigger it. Now awaiting a siege. Oh, wait, I've still got a couple caged enemy dorfs. BRB.
OK. Soldiers stationed in sight of an enemy when it appears will attack it on their own. No trouble, give or take for personal sight range and stealth issues. Soldiers off duty and told to attack will attack, no problem. Soldiers on station but not yet attacking because they haven't seen the enemy, when told to attack they have pathing problems, often failing to path, never doing that quick movement, and when they do get near an enemy they say they can't reach the target and rarely attack (though they do rarely, shown against KO'd enemies, so I think they've just failed to enter combat-time).
So what if it's failing to enter combat mode (including the pathfinding-to-enemy code) because the game assumes they're already in it? They will actually wander "close" to the x-y-z of the location given for the attack order as if they're stationing, but never enter combat time.
Right, I repeated it a few times. When under station orders, a dorf will flick to combat mode on seeing an enemy. When under kill orders directly from training or idling or anything else, a dorf is always in combat mode. When shifted directly from station to kill orders, a dorf does not and then cannot flick to combat mode and just tries to station near enemies and only rarely attacks. That repeats for me, regardless of on-duty or off-duty.
Possible workaround: 1: Station, 2: Cancel orders, 3: advance 1 tick, 4: Kill?
ARHGHGH. That doesn't work. They need to take up another job first, otherwise they're still stuck. Someone wandered off and did something or other and then immediately got into combat mode and killed the target. There's something left set from station orders that breaks the kill order until they do some other job.
Huh. Stone traps can hit an enemy multiple times, the stone sort of bounces around and keeps on bashing them. Is that new?
[...]
I bet it's a function pointer. The station order will change the link for each dorf's pathing function to the stationing one where they move to a place scattered around the target on the same floor level and then stand there, and if they sight an enemy from there it's changed to the normal pathfinder and flicks on a combat time switch for it (that's why different z-levels bug it worse). The job assigner sets the path function back to the normal one too, but kill orders don't, they just flick on the combat time switch, and that doesn't work with the station pathing function (because you're not supposed to be in station pathing mode any more with combat time, so it chucks a vague "can't path" error). Anyone moving to station, or doing anything with alternate pathing functions will fail to enter kill orders correctly.
So the more often a formerly-stationed dorf gets hit, the more they trigger their pathfinder, and the worse it bugs out. When I get them near KO'd enemies (thus the rock traps) they can still attack if they happen to end up pathing over the square of the enemy. Cool, seems to fit.