GNU bug report logs - #67132
[Shepherd] Bogus value from PID file can prevent service from being stopped

Previous Next

Package: guix;

Reported by: Ludovic Courtès <ludo <at> gnu.org>

Date: Sun, 12 Nov 2023 17:47:01 UTC

Severity: normal

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 67132 in the body.
You can then email your comments to 67132 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#67132; Package guix. (Sun, 12 Nov 2023 17:47:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ludovic Courtès <ludo <at> gnu.org>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Sun, 12 Nov 2023 17:47:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: bug-guix <at> gnu.org
Subject: [Shepherd] Bogus value from PID file can prevent service from being
 stopped
Date: Sun, 12 Nov 2023 18:45:38 +0100
Hi,

‘terminate-process’ in (shepherd service) assumes that, once it has sent
SIGKILL to a given PID, it eventually gets a SIGCHLD notification for
that PID.

Unfortunately there are corner cases where it doesn’t hold.  Take PID 2:

--8<---------------cut here---------------start------------->8---
$ ps x 2
  PID TTY      STAT   TIME COMMAND
    2 ?        S      0:00 [kthreadd]
--8<---------------cut here---------------end--------------->8---

That’s not a “real” process, so when you (kill 2 SIGKILL), nothing
happens.  Thus, ‘terminate-process’ never returns; the corresponding
service stays in “stopping” state and you cannot halt your machine.

You may wonder how we end up calling ‘terminate-process’ with a “bogus”
PID.  It normally never happens, but it can happen with a combination of
‘make-forkexec-constructor’ with #:pid-file and
‘least-authority-wrapper’: the PID file of the wrapper may read “2” (the
PID inside the least-authority PID namespace), so ‘herd stop’ on that
service will end up doing (kill 2 SIGKILL).

Ludo’.




Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Wed, 22 Nov 2023 10:17:01 GMT) Full text and rfc822 format available.

Notification sent to Ludovic Courtès <ludo <at> gnu.org>:
bug acknowledged by developer. (Wed, 22 Nov 2023 10:17:02 GMT) Full text and rfc822 format available.

Message #10 received at 67132-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: 67132-done <at> debbugs.gnu.org
Subject: Re: bug#67132: [Shepherd] Bogus value from PID file can prevent
 service from being stopped
Date: Wed, 22 Nov 2023 11:16:37 +0100
Ludovic Courtès <ludo <at> gnu.org> skribis:

> ‘terminate-process’ in (shepherd service) assumes that, once it has sent
> SIGKILL to a given PID, it eventually gets a SIGCHLD notification for
> that PID.
>
> Unfortunately there are corner cases where it doesn’t hold.  Take PID 2:
>
> $ ps x 2
>   PID TTY      STAT   TIME COMMAND
>     2 ?        S      0:00 [kthreadd]
>
> That’s not a “real” process, so when you (kill 2 SIGKILL), nothing
> happens.  Thus, ‘terminate-process’ never returns; the corresponding
> service stays in “stopping” state and you cannot halt your machine.

Fixed in Shepherd commit cc9c5c029534458ae547d78200b6b51f729654e3.

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 20 Dec 2023 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 180 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.