Summary
Commit 82f05bc ("build: Fix include copying, references and RT/non-RT isolation") removed ~30 headers from SRCHEADERS, so they are no longer copied from src/emc/{motion,tp,kinematics,ini,nml_intf}/ to include/. Direct -I flags were added so source files find them in src/ instead.
However, the existing stale copies in include/ were never deleted, and make clean / headersclean no longer removes them (since they're no longer in HEADERS). Any working tree that existed before the commit retains the old copies.
Impact
The stale include/ headers silently shadow the real src/ headers when both are in the -I search path (which they are — -I../include appears in compile flags). If a struct-size-affecting field is added or removed in src/, the stale include/ copy keeps the old layout. This causes:
- Shared memory size mismatch between motmod (finds
src/emc/motion/motion.h) and milltask (finds include/motion.h via -I../include), resulting in shmget(): Invalid argument (EINVAL) at startup
- Silent shared memory corruption if the sizes happen to match but layouts differ
The specific error:
rtapi_shmem_new failed due to shmget(key=0x00000064): Invalid argument
MOTION: rtapi_shmem_new failed, returned -22
MOTION: init_comm_buffers() failed
Affected headers
All headers removed from SRCHEADERS in 82f05bc that may still exist in include/:
motion.h state_tag.h axis.h blendmath.h simple_tp.h spherical_arc.h
usrmotintf.h tc.h tc_types.h tcq.h tp.h tp_types.h homing.h switchkins.h
cubic.h genhexkins.h genserkins.h pentakins.h pumakins.h motion_types.h
sp_scurve.h canon.hh canon_position.hh emctool.h emc.hh emc_nml.hh
emccfg.h emcglb.h interp_return.hh emcIniFile.hh iniaxis.hh inijoint.hh
inispindle.hh initraj.hh inihal.hh
Suggested fix
Either:
- Add an explicit
rm -f for these files in the commit (or a follow-up), so users pulling the change get them cleaned automatically
- Add them to
headersclean / make clean so they are always swept
Option 2 is more robust since it handles any future SRCHEADERS removals.
Reproduction
- Have a working tree with
include/ populated from before 82f05bc
- Pull the commit (headers stop being updated but stale copies remain)
- Make any struct-size-affecting change in
src/emc/motion/ or src/emc/tp/
make clean && make — stale include/ copies are not cleaned
- Launch LinuxCNC —
shmget fails with EINVAL due to size mismatch
Summary
Commit 82f05bc ("build: Fix include copying, references and RT/non-RT isolation") removed ~30 headers from
SRCHEADERS, so they are no longer copied fromsrc/emc/{motion,tp,kinematics,ini,nml_intf}/toinclude/. Direct-Iflags were added so source files find them insrc/instead.However, the existing stale copies in
include/were never deleted, andmake clean/headerscleanno longer removes them (since they're no longer inHEADERS). Any working tree that existed before the commit retains the old copies.Impact
The stale
include/headers silently shadow the realsrc/headers when both are in the-Isearch path (which they are —-I../includeappears in compile flags). If a struct-size-affecting field is added or removed insrc/, the staleinclude/copy keeps the old layout. This causes:src/emc/motion/motion.h) and milltask (findsinclude/motion.hvia-I../include), resulting inshmget(): Invalid argument(EINVAL) at startupThe specific error:
Affected headers
All headers removed from
SRCHEADERSin 82f05bc that may still exist ininclude/:Suggested fix
Either:
rm -ffor these files in the commit (or a follow-up), so users pulling the change get them cleaned automaticallyheadersclean/make cleanso they are always sweptOption 2 is more robust since it handles any future
SRCHEADERSremovals.Reproduction
include/populated from before 82f05bcsrc/emc/motion/orsrc/emc/tp/make clean && make— staleinclude/copies are not cleanedshmgetfails with EINVAL due to size mismatch