Subject: Re: bug#77373: [shepherd] Deadlock between service-controller and service-builtin-logger

From: Ludovic Courtès <[email-masked]>
Date: Sun, 30 Mar 2025 16:44:24 +0200

Hi nathan,

nathan <[email-masked]> skribis:

> I definitely have a deadlock problem with Shepherd and I do believe I've found it.
> shepherd 1.0.3

Could you explain exactly how that happens (sequence of actions leading
to the deadlock) and share the relevant /var/log/messages excerpt?

> This is in service-controller when the service has been stopped:
> (when logger
>   (put-message logger 'terminate))
> But in service-builtin-logger, this is called every time a line is read:
> (or pid
>     (and service
>          (eq? 'running (service-status service))
>          (match (service-running-value service)
>            ((? process? process)
>             (process-id process))
>            (value
>             value))))
>
> service-status -> service-control-message -> put-message to the service
> The fibers documentation says put-message is blocking. Surely this is a deadlock.

Yes, but only if ‘pid’ hasn’t been cached before, which I think would
mean that not a single line was logged before stopping the service.

I’ll take a closer look.

Thanks for reporting it and for investigating!

Ludo’.