Sebastian,

I made an issue on Monday that also speaks to this race condition that's
been exposed by the recent iocontrol moves.

Here is the issue:  https://github.com/LinuxCNC/linuxcnc/issues/2700

I am not sure if Rene is on the dev list, so it might be prudent to make
these observations in the issue I created?  If nothing else, it's tracked
that way.

Thanks,

Greg

On Wed, Oct 18, 2023 at 5:21 PM Sebastian Kuzminsky <s...@highlab.com> wrote:

> When the `linuxcnc` script launches linuxcnc it starts Task, then loads
> motmod (as one of the commands in the [HAL]HALFILE list).
>
> I believe this is racey, leading to at least some of the intermittent
> failures on the buildbot.
>
> Task does this at startup:
>
> 1. Runs `usrmotInit()` which connects to the emcmotStruct shm, including
> emcmotCommand and emcmotStatus.
>
> 2. Runs `usrmotWriteEmcmotCommand()` to copy the first initialization
> command into emcmotCommand, then polls emcmotStatus waiting for motmod
> to echo the first command's commandNum.
>
> 3. If the commandNum does not echo in emcmotStatus within a timeout,
> Task gives up on the command.
>
> Motion/motmod does this at startup:
>
> 1. Runs `init_comm_buffers()` to connect to the emcmotStruct shm,
> including emcmotCommand and emcmotStatus.  Calls `memset()` on
> emcmotStruct to initialize it to all-bytes-zero.
>
> 2. Start polling emcmotCommand for new commands (this happens in a hal
> thread via the `motion-command-handler` function).
>
> The race happens when Task does its 1 and 2, then Motion does *its* 1,
> discarding Task's first command.
>
>
> I think the recent move of iocontrol into Task changed system timing and
> made this race more likely to bite.
>
> Any thoughts?
>
>
> --
> Sebastian Kuzminsky
>
>
> _______________________________________________
> Emc-developers mailing list
> Emc-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-developers
>

_______________________________________________
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to