Skip to content

Move the LinuxCNC patch series to v2.10.0-pre2 (experimental) - #164

Draft
b0czek wants to merge 45 commits into
mainfrom
exp/pre2
Draft

b0czek wants to merge 45 commits into
mainfrom
exp/pre2

Conversation

@b0czek

@b0czek b0czek commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Moves the LinuxCNC base from 888cb941fb (2026-06-04) to the upstream tag v2.10.0-pre2. Still a draft until reviewed.

What changes at pre2

  • Upstream replaced the HAL API (opaque handles with getters/setters, 64-bit integers only) and stopped exporting HAL internals. Patches that add pins, and the native server's HAL adapter and scope controller, were ported to the new API rather than rebased.
  • 1089 upstream commits lie between the two bases; 15 of the 23 patches conflicted textually.

Series

  • base-revision points at v2.10.0-pre2. Every patch is ported; pending-pre2/ is gone.
  • Patch numbers are permanent. A removed patch leaves a gap and stays in the README, struck through; apply.sh and refresh.sh accept gaps.
Patch On pre2
0001-0003 Ported. 0003 also keeps the interpreter's new G96 D limit modal
0004 Ported, with review fixes: Stop finishes chained G33 moves, STOPPED is reported only at rest, Stop during G28.2 homing waits for it. New: Resume waits for spindle at-speed before motion continues, and commands read behind a thread (M5, S, M9) run after Resume instead of being undone by it
0005 Rebuilt on upstream's --disable-gui / --disable-manpages
0006 Ported
0007 Follows upstream's split of #5401-#5409 (stored) and #5081-#5089 (applied); tool and offset now switch together; 510-character tool lines
0008 Tapered passes go through upstream's G76 synchronized-feed check
0009-0015 Ported. 0011 splits tests/resumable-stop into four parallel tests. 0012's refusal of DB_PROGRAM skips upstream's new tests/tooldb
0016-0018 Ported; acquisition homing now uses upstream's G28.2 home cycle
0019, 0020 Ported
0021, 0023 Ported
0022 Removed: upstream already defines HAL_NAME_LEN as 55
0024 New: fixes a milltask crash after E-stop, machine off, mode change or re-init while an MDI remap waits (also in plain pre2)

The README inventory describes each patch's differences on pre2.

Native server

The HAL adapter and scope controller use the public HAL query API. HAL integers are reported as 64-bit with the protobuf contract unchanged; the Dockerfile and CI build LinuxCNC with --disable-gui / --disable-manpages.

Verification

  • Locally on the full stack: clean -Werror build, 351/351 LinuxCNC regression tests (5 skipped), headless build with a test subset.
  • CI: LinuxCNC patch tests (now four shards) and CI (native build and test, lint, format, simulator container).

Final review

Six parallel reviewers went over the applied tree; findings are in the PR comment. Fixed here (commits 3cb46e8, 6779ca1, b852de8):

  • 0004: Pause while Resume is pending cancels it like a second Stop (was overridden once the spindle reached speed); a spindle restored at S0 no longer holds Resume forever.
  • 0007/0012: a failed save after a random-changer M6 is reported; a tool table that fails to load blocks saves until it loads, so one bad line can no longer lead to the file being overwritten. CRLF/whitespace/comment-only lines are blank.
  • 0017/0018: M54's acquisition home is not issued while stopped or paused; motion-side timeout restored; trajectory mode restored after an aborted acquisition.
  • 0019: individual homing is refused while another joint homes if either uses HOME_IS_SHARED or HOME_IGNORE_LIMITS.
  • 0024: interpreter reset drops MDI state only when an interrupted call exists.
  • Native: writes outside an owned S32/U32 item's range are refused with FAILED_PRECONDITION again (as on main); live test covers 64-bit integer scope channels.

Deferred findings (all also on main or low severity) are tracked in #166, #167, #168, #169, #170.

@b0czek

b0czek commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner Author

Final review findings (6 parallel reviewers on the applied v2.10.0-pre2 tree). Group A plus B1 and B2 are being fixed in this PR; the rest are to be filed as issues.

Applied tree used: LinuxCNC v2.10.0-pre2 + series (branch review in pre2-review-linuxcnc).
"Verified" = re-checked against the code by the coordinator, not only by the reviewer.
"On main" = also present in the old series on main.

A. New or worsened on pre2

# Sev Patch Finding On main Verified
A1 high 0004 Pause during STARTING (or after Resume latched in STOPPING) is overridden: STARTING calls emcTrajResume() and clears task_paused when at-speed arrives, so queued motion runs while UI shows paused. Window is now the whole spindle spin-up. emctaskmain.cc:1161-1173, 3118. tiny window only yes
A2 med 0024 EMC_TASK_PLAN_INIT during a plain MDI move calls mdi_execute_abort() unconditionally → interpState IDLE while still moving, task.command never cleared. gRPC kResetInterpreter isn't idle-gated. Fix: only call when wait/next/level>=0/queue non-empty. emctaskmain.cc:3161. no yes
A3 med 0017/0018 Stop while availability is ENABLING (before HW ACK) goes straight to STOPPED; then task issues the acquisition EMC_JOINT_HOME and the joint homes while STOPPED. Same for Pause. emctaskmain.cc:3505-3522, 1074. probably similar no
A4 med 0007/0012 Random changer: failed tooldata_save after M6 sets ERROR, then overwritten with DONE (taskclass.cc:356 → :923). 0007's "never save a table with a refused >510-char line" makes this fail on every change → pocket map on disk goes stale silently. upstream bug, new trigger yes
A5 med native 64-bit write to a remote component's S32/U32 item is accepted and echoed, but the owner reads it clamped to 32 bit. main rejected it with FAILED_PRECONDITION. adapter.cc:176-195, 397-402. no no
A6 low 0004 STARTING waits forever if the restore doesn't change commanded speed (M3 S0, override 0%) and at-speed is comparator-based (stays true; fresh false required). No timeout/message. taskintf.cc emcSpindleStopRestoreAtSpeed. no no
A7 low 0017 Motion-side timeout dropped for WAIT_HOME_REQUEST/WAIT_FREE; motion can stay in HOMING, rejecting jogs/moves until abort. Task 2 s error path restores mode before abort → left in FREE. control.c:873-889. no no
A8 low native Client-visible changes: all ints reported S64/U64; CreateSignal(S32) answers S64; uses_fp always true; per-thread components now listed. Release-note material. Live test grpc_live_hal.cc:588 still looks for S32/U32 scope pins → never tests integer scope channels. no no
A9 low native Thread "running" probe sleeps up to 100 ms on the shared HAL worker and can flap topology events on NRT stalls; no tests. adapter.cc:601-672. no no
A10 low 0024 Test doesn't verify queued MDI commands are dropped (only one command per scenario). — no

B. Pre-existing (also on main)

# Sev Patch Finding Verified
B1 high 0019 Concurrent individual homing ignores HOME_IS_SHARED: home X, then Y while switch open → X closes shared switch, Y latches at wrong position. Upstream refused any concurrent home. command.c:1778-1789. Fix: refuse concurrent if either joint has HOME_IS_SHARED (or HOME_IGNORE_LIMITS). yes
B2 med 0012 One unrecognised tool.tbl line (e.g. CRLF blank line) aborts the whole load; emcIoInit ignores the failure → empty table; next tool create saves a file with only that tool → other tools lost on disk. tooldata_common.cc:415, taskclass.cc:406. yes
B3 med 0004/0011 Step from STOPPED with empty queue (Stop during G4/M66/M6/M19): emcTaskStepInterpreter sets interpState = interpResumeState (IDLE) without PAUSED check → program appears finished mid-file; EMCMOT_STEP refuses with empty queue and leaves tp stopping/pausing set. emctaskmain.cc:958-967. yes
B4 med 0014 css_maximum published at read-ahead time (SET_SPINDLE_MODE), not execution; M2 read-ahead zeros it during the cut; G96 without D publishes 1e30. emccanon.cc:2870. yes
B5 med? 0011 In-flight Step target can be re-blended by later-queued segments (term_cond overwritten, parabolic blend starts next block). Uncertain. tp.c:4687, 2142, 1646, 4593. no
B6 med? 0011 In-flight Step inside a G33 chain: pause doesn't hold sync segments, so next G33 runs while status says paused; stops mid-segment. Uncertain. tp.c:4669-4690. no
B7 low 0020 Power jog toward an unavailable X/Z joint disables motion instead of being refused. command.c:160-171. no
B8 low 0004 Stop accepted in AUTO with interp IDLE while a GUI tool command is queued → next Run consumed as Resume. emctaskmain.cc:2808. no
B9 low 0007 Remapped M6/M61 gets no automatic offset; RETAIN_G43 removed and silently ignored. no
B10 low 0007 AXIS tooledit drops lines with W* fields (deletes tools with wear on save); gladevcp tooledit breaks too. no
B11 low 0007/0012 0007's DB_PROGRAM code/tests dead once 0012 refuses DB_PROGRAM; README still describes them. tool-line-length test passes on any rs274 failure. no
B12 low 0003 EMC_TASK_PLAN_INIT resets interp to G97 but canon keeps css_maximum → S word interpreted differently by interp vs motion. no
B13 low 0010 M2/M30 drop cutter comp without emitting STOP_CUTTER_RADIUS_COMPENSATION in recorded stream. no
B14 low 0013 Executor timeouts keep counting during Stop/Pause → long resumable Stop becomes INTERP_ERROR on Resume. no
B15 low 0011 Source-block step target only covers already-queued segments. no
B16 low 0005 Headless launcher can still call wish (stale lock, no tty, DISPLAY set). scripts/linuxcnc.in:745. no
B17 low 0021 halcompile --install with --cc/--ld but no --cross-prefix installs foreign .so into host dir. no
B18 low native Scope ring wraps at (buf_len/16)*16 but controller uses % buf_len → wrong cells when scope_samples % 16 != 0. no
B19 low native Integer trigger level truncated toward zero instead of floor (−3.5 → −3). sample_codec.hpp:241. no
B20 low 0004 tests css / queued-feed-atspeed / multi-spindle tests don't prove what README claims. no
B21 uncertain 0007 T0 M6 under G43.4 becomes G49 → drops TCP kinematics (new on pre2; decide if intended). Synch restores offset but not G43/G49 modal. no

Clean

0001, 0002, 0006 (security; note: extra trusted dirs must be root-owned with setuid rtapi_app — README sentence), 0008 geometry, 0009, 0015, 0016, 0023, 0022 removal, apply/refresh gap handling, shard distribution (356 tests, each once), configure flags, scope ABI, HAL query lock handling.

@b0czek

b0czek commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner Author

PR #164 (exp/pre2) — review round 2, on b852de8

Static review only: nothing was built or run for this round, and no finding has been reproduced.
Line numbers: LinuxCNC tree = v2.10.0-pre2 + series; native paths are repo-relative.

  • "Verified" = re-checked against the code by the coordinator, not only by the reviewer.
  • "Origin": R1 = caused or exposed by the round-1 fixes; pre2 = new with the port; main = also in the old series; upstream = in plain upstream.

High

H1-H4 are fixed in 28896de. The halui.program.stop item was withdrawn as intended behaviour (see L18).

# Patch Finding Origin Verified
H1 0012 Reload of a table that loaded fine at startup can block all saves until restart. valid_table rejects P >= 1001 even on non-random changers (configs/sim/axis/sim.tbl has T99999 P99999); any rejection of the configured file now sets the save block, with no operator message. taskclass.cc:612-620, 727. R1 yes
H2 0004 Stop, Resume, Stop during STOPPING: second Stop hits default, latch survives, at rest the spindle/coolant restore and the program continues. emctaskmain.cc:2863-2879, 1159-1162. main path; R1 comment claims otherwise yes
H3 0011 Pause does not stop an active Single Step: EMCMOT_PAUSE keeps stepping, tpPause re-enters the step branch, pausing = 0; block or G76 pass runs out while status says paused. Also re-saves the overwritten term_cond. command.c:1498, tp.c:4662-4691. main yes
H4 0007/0012 Random changer: after a failed save, the documented recovery (fix file, reload) accepts a file whose spindle slot differs from toolInSpindle (find_tool accepts any slot), so the wrong tool/offset becomes active. taskclass.cc:614-616, 395. R1 message leads here yes

Medium

# Patch Finding Origin Verified
M1 0024 PLAN_INIT keeps queued MDI commands, which then run under reset modal state (queued G0 X1 written for G91 runs as G90). emctaskmain.cc:3198. R1 yes
M2 0024 A2 fix incomplete: MDI G38.2/M66/M6/G28.2 set mdi_execute_wait with no call; reset still shows IDLE while running and task.command never clears. Needs wait re-asserted after init. emctaskmain.cc:3094, 3198. R1 incomplete yes
M3 0012 Loading a different table clears the save block; next save overwrites the protected file. taskclass.cc:623. R1 partly yes
M4 0012 Start with table missing, create it in an editor, no reload: next save replaces it. Store file identity at load, refuse save on mismatch. tooldata_common.cc:470. R1 yes
M5 0012 Save replaces a symlinked table with a regular file (rename on link path); also breaks same_file. tooldata_common.cc:521-536. main yes
M6 0012 Random changer: fixing a table that failed at startup leaves toolInSpindle and the HAL pin at 0. taskclass.cc:244-249. R1 leads here no
M7 0012 Rejected tool update/delete enters EXEC::ERROR: aborts, stops spindle and coolant, closes the program, no operator message. Reachable from gRPC DeleteTool for an unknown tool. taskclass.cc:778-785, 854; emctaskmain.cc:3513, 3442; native command_validation.cc:151. main yes
M8 native A queued command's failure is credited to the next command: echo moves to N+1, N resolves Completed, N+1 Rejected. nml_adapter.cc:283-289; emctaskmain.cc:4400, 4567. main yes
M9 0007 G10 save failure: only rcs_print_error, io ERROR, abort, then status cleared: program dies with no operator message; MDI G10 can report DONE. taskclass.cc:680-683; emctaskmain.cc:4486. pre2 base + 0007 trigger yes
M10 0017, upstream Home finishing between status reads (absolute encoder, HOME_NO_REHOME already homed, zero velocities) is reported "G28.2 home did not start" and fails the program. Likely cause of the flaky runtime-availability-regressions. emctaskmain.cc:3715-3735; homing.c:871. Fix: monotonic home-started counter. upstream, inherited yes
M11 0019 Out-of-tree homing modules without the required symbols fail to load motmod, no clear message. command.c:1794. R1 partly no
M12 native Writes to non-owned 32-bit consumers are acknowledged then truncated: axis.N.jog-counts read by hal_get_si32 (wraps); 2147483648 becomes negative; can jog the wrong way in teleop with jog-enable. Same for halcompile si32 pins. adapter.cc:325-336; axis.c:425. pre2 (main refused) yes
M13 native tests New tests pass with the signal walk, alias candidate, param path or narrow->remove broken. grpc_live_hal.cc:417; hal_value_codec_tests.cc. R1 no
M14 0012 tests Startup half of garbage-ui.py passes without the save block (G10 fails on empty table before any save). garbage-ui.py:17-20. R1 no
M15 0010 Preview uses wrong tool data after M6/M61/G10 (entry 0 stale, G10 lost at reload). recordingcanon.cc:441-458. main no

Low

# Patch Finding Origin
L1 0024 tests "Queued MDI dropped" check cannot fail: set_mode runs first and clears the queue. test-ui.py:125-131. R1
L2 0009/0004 Pause during STOPPING can stall a G76 Stop with an undelivered retract. emctaskmain.cc:3481; tp.c:4380. main
L3 proto WAITING_FOR_KINS_SWITCH (11) and WAITING_FOR_HOMING (12) missing from ExecState; clients get undeclared values (verified). machine.proto:50-61. pre2
L4 0017 Overrides and similar commands refused during an availability operation. emctaskmain.cc:1296-1320. main
L5 0020 Power-jog release during E-stop/machine off is lost; next press refused once. halui_power_feed.hh:47. main
L6 0019 tests Sub-test removal lost state-machine error isolation; no absolute-encoder, queued G28.2 or homecomp coverage. R1
L7 native Out-of-range value can reach a narrow pin by linking after the write; comments overclaim. adapter.cc:337. R1
L8 native Error text doesn't mention out-of-range. service_hal.cc:292. R1
L9 native Signal writes walk all pins per write under the HAL mutex. adapter.cc:338. R1
L10 0007 tests random-ui.py passes if ERROR is overwritten with DONE again. random-ui.py:51. R1
L11 0012 One-character bodies (X;note, trailing Ctrl-Z) now fail the whole file. tooldata_common.cc:125. R1
L12 0012 Random M61 Q<spindle tool> with blocked saves self-swaps and aborts. taskclass.cc:882. R1
L13 0012 Deleting a broken file leaves the save block set. tooldata_common.cc:471. R1
L14 0012 Random changer with missing table: tool create always fails (zeroed slots look occupied). tooldata_mmap.cc:159. README claim
L15 0007 510-char CRLF line refused; over-long comment line blocks saves. tooldata_common.cc:401. exposed
L16 0012 Missing file reports "corrected and reloaded" at every start. taskclass.cc:415. R1
L17 0007/0012 Comment-only lines are dropped on first save (documentation). main
L18 0004 Not a bug: halui.program.stop is documented as the resumable Stop, rejected without an active AUTO program; halui.abort is the full abort. Compatibility only: configs wired to the old pin meaning (xhc-hb04 samples reference it) no longer get an abort. Needs a migration note. Withdrawn from High after review. main

Uncertain (not counted)

Pause during STOPPING on a G76/G33 blend arc may clear the Stop target; motion timeout can beat task's 2 s check with AVAILABILITY_TIMEOUT <= 2 s; emcOperatorError may stall task if the error channel doesn't drain; SET_JOINT_HOMING_PARAMS during homing; shared HAL index signal; owned S64 OUT/IO pin linked to an S32 IN.

Allow gaps in the patch sequence so a removed patch does not force the
rest of the series to be renumbered. apply.sh and refresh.sh now require
ascending four-digit numbers instead of contiguous ordinals, and
refresh.sh numbers an appended patch after the highest existing one.

Document the rule: numbers are never changed or reused, and a removed
patch stays in the README inventory, struck through, with the reason.
Pin the base to the v2.10.0-pre2 tag and park every patch that still
applies only to the previous base under pending-pre2/, where the tooling
ignores it. Each patch returns to the series, with its number and
filename unchanged, when its port is accepted.

Remove three patches and strike them through in the inventory:

- 0017 and 0018: runtime availability is being redesigned around
  upstream's new G28.2 and will return as a new patch.
- 0022: upstream already defines HAL_NAME_LEN as 55.

The series is empty until the first ports land, so the patch workflow
cannot pass on this commit.
LinuxCNC 2.10 no longer exports HAL's private list walkers and shared-memory
base; consumers inspect HAL through the public query API (hal_list_*,
hal_get_*, hal_set_*), whose callbacks run while HAL's mutex is held.

hal/query.hpp wraps those calls for C++ callables. It catches exceptions
thrown by a callable, stops the iteration and rethrows after HAL has
released its mutex, so an exception can never leave HAL locked. with_lock()
holds the recursive, per-thread HAL mutex around several queries so they
observe one consistent HAL state. The header is shared by the HAL adapter
and the scope controller.
The adapter walked HAL shared memory through hal_priv.h (SHMPTR,
halpr_find_*, hal_data lists and mutex) and created items with
hal_pin_new/hal_param_new. LinuxCNC 2.10 removes all of that: pins and
parameters are opaque 64-bit handles and HAL is inspected through the
query API.

- Listing, reads and writes use hal_list_*, hal_get_p/s and hal_set_p/s.
  Each adapter call holds HAL's mutex once, as before, so topology(),
  read_many() and write_many() still see and change a consistent state.
  Write rules are unchanged: unlinked non-output pins, HAL_RW parameters,
  signals without a writer.
- HAL integers are 64-bit only. Items are reported as BIT, FLOAT, S64 or
  U64; S32 and U32 values are accepted as writes to S64 and U64 items, and
  CreateSignal with S32/U32 creates a 64-bit signal.
- Owned remote-component items keep their declared type. A 32-bit item is
  created with hal_pin_new_si32/ui32 (64-bit storage) and its owner reads a
  value outside the 32-bit range clamped to the nearest limit.
- Function and thread statistics come from the <name>.time pin and the
  <name>.tmax and <name>.tmax-increased parameters. HAL dropped the
  floating-point flag, so uses_fp is always true. HAL no longer publishes
  whether threads run; it is derived from <thread>.threadbeat advancing
  between topology() calls. Thread function lists exclude init functions.
- The CMake HAL gate checks for hal.h instead of hal_priv.h.
0001 and 0002 apply unchanged. 0003 now also keeps the interpreter's
css_maximum (the G96 D limit upstream added for the G33/G76 pitch check)
modal: it is initialized in Interp::init(), preserved across
Interp::synch() and cleared by M2/M30, like the spindle mode. Canon
keeps its own CSS limit across a mode switch, so resetting only the
interpreter's copy made legal threading moves fail after any switch.

The three patches build with -Werror on v2.10.0-pre2 and the upstream
regression suite passes (324 of 324).
…c API

The controller found scope sources, threads and functions by walking HAL's
private shared memory (hal_priv.h, SHMPTR, halpr_find_*, hal_data lists and
mutex, hal_shmoff). LinuxCNC 2.10 removes all of that. Follow upstream's own
halscope port (d88d10d, "hal: Update halmeter and halscope removing access to
hal_priv.h"):

- Sources resolve with hal_getref_p (HAL_QTYPE_PIN or HAL_QTYPE_PARAM) and
  hal_getref_s, and hal_reference_unmap() turns the returned reference into
  the offset scope_rt maps back with hal_reference_map(). A linked pin still
  samples its signal's value and an unlinked pin its own value; HAL now does
  that choice inside hal_getref_p. configure() resolves all channels, the
  thread period and the attached thread under one hold of HAL's mutex, as
  before.
- scope.sample, its thread and thread periods come from hal_list_funct and
  hal_list_thread; the owner check uses hal_list_comp.
- scope_rt's shared-memory layout changed: data_offset[] is rtapi_intptr_t,
  the sample union holds rtapi_bool/uint/sint/real, and the buffer starts at
  the control block rounded up to 8 bytes. shm_abi.h follows it. The
  compatibility check now requires buf_len to equal the buffer length implied
  by our layout instead of only fitting in the segment, so a module with a
  different control block is rejected in either direction.
- scope_rt samples each type into a full 8-byte cell. BOOL and REAL decode
  exactly; SINT and UINT are 64-bit and decode to the channel's doubles,
  exactly up to 2^53 and rounded beyond. Trigger levels for SINT/UINT
  channels are validated against the 64-bit ranges ("S64"/"U64" errors).
  HAL_PORT items are rejected as before.
- Every failure after hal_init in the constructor now tears down, including
  HAL query errors.

The conversion and trigger-level code lives in scope/sample_codec.hpp so the
contract test can check it against upstream's scope_data_t, together with
the new layout.
LinuxCNC 2.10 has no public equivalent of hal_data->threads_running:
hal_start_threads() and hal_stop_threads() only flip that private flag, and
the only effect a process can observe through the public API is each
thread's <thread>.threadbeat pin advancing once per period while threads
run. The adapter therefore keeps deriving "running" from the beats, but a
fresh adapter counted any non-zero beat as running, so threads stopped
before the process started were reported running until the next call. A
beat that moved since a call long ago had the same problem.

Decide only on evidence instead:
- compared with the previous topology() call, a beat that changed within
  twice its thread period plus 20 ms means running, and a beat unchanged for
  at least that long means stopped;
- otherwise re-read the beats every 1 ms, outside HAL's mutex, until one
  moves (running) or twice the shortest period plus 20 ms passes (stopped),
  for at most 100 ms. Only when no thread is faster than about 40 ms does
  that bound leave the question open; then the previous answer is kept, or
  on the first call a non-zero beat still counts as running.

Measured in a non-realtime uspace container with a 1 ms thread: no extra
wait when called again within the window, about 1 ms when threads run, and
22 ms on the first call while threads are stopped.
Restore patches 0017 and 0018 to the set waiting to be ported and drop
their strike-through in the inventory. They were removed on the
understanding that runtime availability would be redesigned around
upstream's new G28.2; the intent is narrower: only the homing step of
acquisition moves onto upstream's G28.2 homing machinery, and the rest
of both patches is ported as it is.
0004 (resumable Stop) is ported with fixes from two review rounds. Beyond
the port it now reports STOPPED only at rest, keeps a pending spindle
at-speed wait across Stop, finishes a whole chain of G33 moves and a
queued G28.2 homing cycle before STOPPED, and leaves single-step mode on
Resume. Its regression grows from 16 to 23 scenarios, three of them also
run under the trapezoidal planner. A third round of fixes from the
second review is still to come.

0005 is rebuilt on upstream's --disable-gui and --disable-manpages and
reduced to what a backend-only install still needs: optional Tcl without
Tk, no desktop entries, a launcher that never starts the graphical
picker, and the Debian headless and nodoc profiles. --enable-headless
and --disable-build-manpages no longer exist, so the Dockerfile and CI
configure with upstream's options.

0006 (ordered realtime component search path) is ported onto upstream's
rewritten halrmt and rtapi_app loader.

The six patches build with -Werror on v2.10.0-pre2, also with
--with-extra-rtlib-dirs and headless; the regression suite passes
(326 of 326).
Patch 0004 now carries every review fix from the port: the Stop
chain is tracked by a flag instead of a dangling segment pointer,
STOPPED clears the spindle synchronization record, and Stop's spindle
commands no longer leak at-speed or spindle state into later S words.
tests/resumable-stop runs 25 scenarios plus four under the trapezoidal
planner.

Patch 0007 follows upstream's split of #5401-#5409 (stored) and
#5081-#5089 (applied), applies the automatic offset together with the
tool change, refuses M61 under cutter compensation, limits tool lines
to 510 characters and rolls back failed saves.

Patch 0008 passes upstream's G76 synchronized-feed check on every
tapered pass.

Verified on the stack: clean -Werror build, 335/335 regression tests,
tests/resumable-stop three more times, and a headless build with a test
subset.
0009 merges onto the reworked Stop state of 0004 (a sync-run flag plus
the G76 clearance target) and keeps upstream's G76 override lock in
the first pass's Single Step unit. 0011 adds its in-flight scenarios;
tests/resumable-stop now runs 35 scenarios plus four trapezoidal
re-runs. 0010's recording canon matches pre2's canon interface. 0012
keeps 0007's tool-line limit and save refusal; the upstream tooldb
tests that need DB_PROGRAM are skipped because 0012 refuses it. 0013,
0014 and 0015 apply unchanged in substance.

Verified on the stack: clean -Werror build, 336/336 regression tests
(5 skipped), tests/resumable-stop once more (39/39), headless build
with a test subset.
Completes the port of the series. 0017's acquisition homing now runs
through the G28.2 home cycle (task's queued joint home and homing wait)
instead of its own homing wait; everything else in 0016-0018 stands.
0019 lets an independently homed joint finish upstream's bounded
homing return on its own. 0020 uses the opaque HAL API in halui. 0021
and 0023 were ported earlier and replay unchanged. 0022 stays dropped.

pending-pre2/ is empty and removed, together with the migration
section of the README.

Verified on the stack: clean -Werror build, 347/347 regression tests
(5 skipped), tests/resumable-stop once more (39/39), headless build
with a test subset.
After an E-stop, machine off, mode change or interpreter re-init while
an MDI remap or O-word call was waiting, task kept the state that
resumes the call and later resumed a call the interpreter had already
dropped: milltask crashed for a Python remap and an NGC remap's MDI
command hung. The bug is in plain v2.10.0-pre2. Every interpreter reset
now clears that state; tests/remap/mdi-remap-abort covers both remap
kinds and all four triggers.

Verified on the full stack: clean -Werror build, 348/348 regression
tests (5 skipped).
Patch 0004:
- Resume, Run and Single Step from STOPPED wait in STARTING until
  every spindle that Stop switched off reports at-speed again before
  motion continues. A stale at-speed from before the restore does not
  count; a spindle whose at-speed never reads false (unconnected or
  tied true) does not hold Resume.
- While Stop waits for motion to come to rest, task issues only
  commands that add to the motion queue. An M5, S word or M9 read
  behind a thread now runs after Resume instead of being undone by
  Resume's restore.

Patch 0011 splits tests/resumable-stop into four tests sharing one
driver (general, threading, g76-stop, g76-step) with faster programs:
about 2.5 minutes each instead of one 11-minute test. The patch-test
workflow now uses four shards and spreads them one per shard.

Verified on the full stack: clean -Werror build, 351/351 regression
tests (5 skipped), headless build with a test subset; 0004 builds on
its own.
LinuxCNC 2.10 HAL stores integers in 64 bits only, so a pin or parameter
that a remote component declares S32/U32 is a HAL_SINT/HAL_UINT item listed
as S64/U64. HalService.Write accepted any 64-bit value for it and echoed it
back, while the owning client reads it through hal_get_{s,u}i32_clamped and
silently saw the clamped value. Main rejected such writes as mistyped.

The adapter now records owned items declared S32/U32 (by HAL name, matched
against the owning component id and HAL's alias old name) and refuses a write
that does not fit the declared range, written to the item directly or to a
signal an owned narrow pin is linked to. The refusal goes through the
existing "missing, mistyped, or not writable" path, so HalService.Write
answers FAILED_PRECONDITION as on main and a batch applies nothing.

to_hal(), read_owned() and the new fits_declared() move to
hal/value_codec.hpp and get a unit test (widening, signedness refusal, range
check, clamped owner reads). The live HAL test covers rejected out-of-range
S64/U64 writes, batch atomicity and the in-range 32-bit limits reaching the
owner unchanged.
The live scope check selected a pin by HAL_TYPE_S32/U32, which HAL 2.10 no
longer reports, so it always fell back to a bit/float pin and never sampled
an integer channel. It now configures an S64/U64 pin on channel 0 and a
bit/float pin on channel 1, and checks both channels are enabled in the
first telemetry frame.

Also pin the documented CreateSignal behaviour: a signal requested as S32 or
U32 is created and reported as S64 or U64.
Patch 0004: Pause while Resume is pending (STARTING, or a Resume latched
during STOPPING) cancels it like a second Stop instead of being overridden
when the spindle reaches speed. A spindle restored at commanded speed 0 no
longer holds Resume forever.

Patch 0007: a failed tool-table save after a random-changer M6 is reported
as an operator error instead of being overwritten with DONE.

Patch 0012: a table that fails to load (at startup or on reload of the
configured file) blocks every save until a table loads, so one bad line can
no longer lead to the file being overwritten with a partial table. CRLF,
whitespace-only and comment-only lines count as blank. Startup reports the
load failure.

Patches 0017/0018: the acquisition home of M54 is not issued while the
program is stopped or paused; it starts after Resume. Motion times out an
acknowledged home that never starts, and task restores the trajectory mode
once Abort has cancelled the acquisition.

Patch 0019: an individual home is refused while another joint homes if
either joint uses HOME_IS_SHARED or HOME_IGNORE_LIMITS (shared switch or
limit chain could latch a wrong home). Homing modules export
get_home_is_exclusive().

Patch 0024: EMC_TASK_PLAN_INIT drops MDI state only when an interrupted
call exists, so a reset during a plain MDI move no longer reports IDLE
while moving. The test now checks that queued MDI commands are dropped.

New or extended tests: resumable-stop (pause-starting,
pause-latched-resume, resume-s0), tool-line-length-save, tool-table-load,
availability-mcodes, homing-concurrent, remap/mdi-remap-abort.

Verified locally: -Werror build; full regression suite 343/352 with the 9
failures environmental (GUI tests on a --disable-gui build, pyvcp picking
up another install) plus one link failure fixed in this commit and rerun.
Patch 0004: a second Stop during STOPPING cancels a latched Resume, so
the outputs are not restored and the program stays STOPPED.

Patch 0011: Pause during an in-flight Single Step drops the step target
and pauses normally instead of letting the block or G76 pass finish.

Patch 0012: a nonrandom pocket number is only a label, so tables that
load at startup also reload. A refused reload tells the operator why and
blocks saves only when the file differs from the table in use. On a
random changer a reload is refused unless pocket 0 holds the spindle tool.

Tests: resumable-stop stop-latched-resume and pause-inflight-step,
tool-table-load reload runs, tool-line-length-save random reload.

Verified locally: full regression suite 344/352; the 8 failures are the
GUI tests on this --disable-gui build and pyvcp loading another install.
LinuxCNC task reports one result, for the command it read last. A later
command written while a tool or availability command was still queued
therefore took over that command's failure: the queued command resolved
Completed and the next one Rejected.

Hold later normal-priority writes until a task-queued command resolves or
its time limit passes. Abort, stop, pause, E-stop and machine off go first,
and Resume, Step and spindle off pass the hold. A queued command whose
result was overtaken now fails with an unknown outcome instead of
completing.
Move NarrowItemRegistry to a header and unit-test add, remove, owner
mismatch, aliases and re-creation. Extend the live HAL test with linked
signals, pin and parameter aliases, parameters and component re-creation.
Record a simulated write only after the command is tracked, so a status
published in response cannot be mistaken for an older one. Queue the live
Resume case's tool delete after the pause, where Resume really has to pass
the hold.
Patch 0024: an interpreter re-init always drops MDI commands not read
yet, and aborts only an interrupted call. A running command, including
G38.n, M66, M6 and G28.2, keeps its state and finishes normally.

Patch 0012: a refused tool update or delete reports why and fails only
that command. A save is refused while the configured table file differs
from what was last loaded or saved, follows symbolic links, and only
loading that file lifts a save block. On a random changer the first table
to load after a failed startup sets the spindle tool.

Patch 0007: a G10 whose save fails reports an operator error and fails
the command.

Patch 0017: motion publishes the command number of the last home it
started, so a home that finishes between two task status reads is not
reported as "did not start".

Verified locally: 346 of 354 regression tests passed; the 8 failures are
GUI tests on a --disable-gui build.
LinuxCNC's GUIs and GUI tools are out of scope for this repository, so
document that, build the patch test job with the headless package profile
and leave out their tests. halui stays in scope.

Verified by running the workflow's install, build and test steps in clean
Ubuntu 24.04 containers: all four shards passed.
Older remote interfaces and tool database programs join LinuxCNC's GUIs
as out of scope, and patch CI leaves out their tests. Out of scope means
we do not review or fix these features; it does not mean patches remove
them.
Patch 0007 no longer carries tests for tool database programs, which are
out of scope: its db-line-length test and its edits to upstream's
db-g10-offset are gone. The tool wear and tool table tests generate their
lathe configuration from one shared template instead of six copies.
Patch 0004 starts with the four resumable-stop test groups, so patch 0011
no longer replaces its single test script. availability-mcodes generates
its configuration from the shared availability base.

The final patched tree is unchanged apart from the generated fixture and
a corrected test README.
The test copied tool-table-load's INI, which the fixture trim replaced
with the shared lathe template.
Only the native server builds the recording canon, so it now lives in
native/server/src/gcode. Patch 0010 keeps what must be in LinuxCNC: the
cutter compensation canon calls and a thread-safe tool_mmap_user().

Verified locally: native build, unit and live tests, format, lint and
the patch-stack test.
Upstream master uses D on G76 for a spindle start angle, so patch 0008
no longer uses it for the infeed mode. G76.1 takes the same words as G76
and alternates roughing passes; D is refused on both codes.

Verified locally: 346 of 354 regression tests passed; the 8 failures are
out-of-scope GUI tests on a --disable-gui build. Native build, unit and
live tests, format, lint and the patch-stack test passed.
EMC_TASK_PLAN_INIT re-initialises the interpreter at once, whatever task is
doing, so a reset during an MDI move, dwell, jog or queued work swapped the
modes underneath it.

New patch 0025 makes task refuse the reset with an operator error unless
the interpreter, task, the MDI queue and motion are at rest. The check runs
where task handles the command, so it covers every client with no race.
Patch 0024 drops its own EMC_TASK_PLAN_INIT handling and keeps only the
interrupted MDI cleanup on abort.

The native server additionally refuses a reset while a command it wrote
earlier is still in progress, because task may not have seen that command
yet. The live test checks that a reset during an MDI move is refused, keeps
G91, and succeeds after Abort.
Abort, E-stop and machine off went ahead of a hold behind a task-queued
tool edit or availability change, but left the held commands queued, so
work requested before the abort still reached LinuxCNC after it.

These three now use a new Interrupt priority. Under the same lock that
queues them, the coordinator takes every normal command still waiting and
answers it with "cancelled before reaching LinuxCNC". Commands submitted
afterwards are kept; Pause and Stop keep queued work as before. A
cancelled command never runs, but its cleanup does, so a queued Program
Open still rolls back the program it staged.

Unit tests cover held and unheld queues, Pause, later commands and the
cleanup; the live test checks that Abort cancels an MDI command held
behind a queued tool delete.
With alternating infeed, every second roughing pass is mirrored about the
final thread line, so its compound offset lies beyond the final one. The
pass shifted its end by that offset too and fed past the programmed Z:
g76.1 p.1 z-1 i-.1 j.03 k.1 r1 h1 q30 reached Z-1.0231.

A mirrored pass in patch 0008 now keeps its offset at the start, which puts
it on the other flank, and ends where the final pass ends, on cylindrical
and tapered drive lines. The g76-tapered test checks that no G76.1 feed
leaves the programmed Z range in either direction, with exit taper, boring
and a tapered drive line.
The preview recording canon told the interpreter that only X, Y and Z
exist, so it rejected any A, B, C, U, V or W word ("Bad character 'a'
used") and machines with a rotary or UVW axis got no preview.

The preview now builds the axis mask from [TRAJ]COORDINATES the way task
does: every XYZABCUVW letter, in any case, with X, Y and Z when the key is
missing. The parser integration test previews G0 X1 A90 U2 on an X Y Z A U
configuration and checks that the plain X Y Z configuration still refuses
the A word.
…unners

On a loaded CI runner the simulated machine runs slower than real time,
and a resumed tapered G76 program was still running when the fixed 15 s
completion wait ran out. Raise the default wait to 60 s; a passing run
never waits longer than the program takes.
The 301 test files the patches added to LinuxCNC's tests/ now live in
linuxcnc-tests/, with the same layout, and run out of tree with
`scripts/runtests tests <repo>/linuxcnc-tests`. The patches keep only
their changes to upstream tests and the skip file for the DB_PROGRAM test,
which shrinks them by about 13,000 lines.

Tests that reached the LinuxCNC tree through relative paths now use
$EMC2_HOME; remap/executor generates its INI from a template for that.
CI runs both sets and triggers on linuxcnc-tests/ changes.
…cal runs

linuxcnc-tests/run.sh selects the upstream and linuxcnc-tests tests, leaves
out the out-of-scope GUI, remote-interface and tool-database tests, shards
them when SHARD_INDEX and SHARD_COUNT are set, and runs them with runtests.
CI calls it instead of carrying its own copy, so a local run reports the
same set of tests as CI.
- 0009: G76 approach endpoints stay exact so a prequeued Step stops on them.
- 0011: in-flight Step stops at the first block end it can reach with the
  configured deceleration instead of braking hard on short blocks.
- 0013: executor requests wait for earlier queued motion before starting,
  so AUTO read-ahead no longer sets HAL requests during previous moves.
- 0018: M54/M55 are refused while cutter radius compensation is on.
- 0020: out-of-range halui.power-feed.spindle values are refused instead of
  wrapping onto valid spindle indices.
- 0025: a tool edit no longer leaves the plan wait set, which blocked
  interpreter resets on an idle machine.

Tests cover each change; the executor test now checks the error policy.
Stop and Pause now wait for an operation task has already handed to
another subsystem before the machine holds, as an M function runs to its
completion signal on other controls: G28.2 homing, tool changes and other
I/O commands, user M100-M199 programs, executor requests that have started,
and M54/M55 handshakes waiting for their acknowledgment. Stop keeps spindle
and coolant on until then. Abort ends the wait.

- 0004: hold wait check and EMC_TASK_STAT.holdWait; Resume, Run and Step
  during STOPPING are refused instead of being remembered.
- 0013: an executor request keeps being polled while held; a failure or
  timeout while held ends the program and clears the Stop.
- 0017: Stop waits for an availability handshake's acknowledgment.
- proto/native: TaskStat.hold_wait with delta support.
- 0004: setting AUTO or MDI ends a Stop, as the abort it causes does;
  document that threading and rigid tapping use the trapezoidal planner.
- 0013: executor requests are refused under cutter radius compensation.
- 0017: a released spindle counts as at speed for the other spindles.
- 0020: a power jog stops just inside a soft limit, like an ordinary jog.
- 0021: a SYSROOT exported by a cross SDK no longer turns a native
  halcompile build into a cross build.
Step resume state, MDI pause, tool table load during a tool change,
wear on the changed tool, executor StopIteration and poll flag, saved
term cond and sync run target for Step, with tests.
Step from STOPPED with nothing queued resumes motion, motion's abort
drops an armed Step, Stop needs a running program, a Step on a
synchronized run follows the run as it is queued, and a blend under
way at Step arm is finished.
Main added the operator error serial patch (0024 there, 0026 here, after
this branch's own 0024 and 0025) against the old base. Port it onto the
pre2 series; readahead keeps the zero stamp next to pre2's Stop hold.
Task's startup synch is not visible in status, and on a loaded runner it
can still refuse the first reset.

This branch has not been deployed

No deployments
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