Skip to content

task: undo read-ahead modes when an error aborts a program (#4715) - #4727

Open
grandixximo wants to merge 1 commit into
LinuxCNC:2.9from
grandixximo:abort-error-state-restore-2.9
Open

grandixximo wants to merge 1 commit into
LinuxCNC:2.9from
grandixximo:abort-error-state-restore-2.9

Conversation

@grandixximo

Copy link
Copy Markdown
Contributor

Fixes #4715.

When motion rejects a move (a soft limit, for one) or motion or io report an error, task aborts the program. By then the interpreter has read ahead, often as far as the M2 that resets G54 and G17, and it keeps those modes although the machine never reached them. The coordinate system and plane set before the program are lost, and #5220 saved at exit keeps G54.

Repro on 2.9 and master alike, with or without ON_ABORT_COMMAND:

(MDI: G55 G18, then run)
(4715)
G1 X1 F10
G1 X1.5
G0 X100   (beyond MAX_LIMIT: "would exceed X's positive limit")
M2

After the error the interpreter reports G54 G17. Interpreter errors (bad G-code, divide by zero) are not affected: the interpreter stops reading at the bad line.

Why: an operator abort already brings the interpreter back to the modes of the last executed move with emcTaskStateRestore(), from the motion state tag. The two error paths (EMC_TASK_EXEC_ERROR and the motion/io RCS error) skip it. Pressing Abort afterwards does not help either: the tag is gone once motion clears its queue.

Fix: call emcTaskStateRestore() on those two paths, before the ON_ABORT_COMMAND routine runs, in the same order as the operator abort. It acts only in AUTO and only when the tag is restorable (not inside a remap or subroutine), as for the operator abort.

Not covered: an error on the very first move of a program leaves nothing executed to restore from, so the read-ahead modes stay there, as before.

Test: tests/abort/exec-error-modes sets G55 G18, runs into a soft limit with a G56 G19 and an M2 read ahead, and checks G55 G18 remain. It fails without the fix (G17 G54) and passes with it. tests/abort, tests/remap, tests/motion-logger, tests/interp, tests/linuxcncrsh* and tests/halui pass. The same change on master passes the full suite except tests/blendmath, the known GCC 14 build failure (#4670).

On merge-up: master no longer reads [EMCIO]EMCIO (io runs in task), so that line in the test's test.ini can be dropped there.

…4715)

When motion rejects a move (a soft limit, for one) or motion or io report
an error, task aborts the program. The interpreter has by then read ahead,
often to the M2 that resets G54 and G17, and kept those modes although the
machine never reached them. The coordinate system and plane set before the
program were lost, and #5220 saved at exit kept G54.

An operator abort already brings the interpreter back to the modes of the
last executed move with emcTaskStateRestore(). Call it on the two error
paths too, before the ON_ABORT_COMMAND routine runs, as on that abort.

tests/abort/exec-error-modes sets G55 G18, runs into a soft limit with a
G56 G19 and an M2 read ahead, and checks G55 G18 remain.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant