From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id cB3xK9tz2WKJJAAAbAwnHQ (envelope-from ) for ; Thu, 21 Jul 2022 17:42:19 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id sMHGK9tz2WI7BQEAauVa8A (envelope-from ) for ; Thu, 21 Jul 2022 17:42:19 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7C2963D7D1 for ; Thu, 21 Jul 2022 17:42:19 +0200 (CEST) Received: from localhost ([::1]:41752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEYJe-0006pG-MR for larch@yhetil.org; Thu, 21 Jul 2022 11:42:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEYHS-000391-Jr for bug-guix@gnu.org; Thu, 21 Jul 2022 11:40:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:48943) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oEYHS-0003iX-9L for bug-guix@gnu.org; Thu, 21 Jul 2022 11:40:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oEYHS-0000Im-4T for bug-guix@gnu.org; Thu, 21 Jul 2022 11:40:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#56674: [Shepherd] Use of =?UTF-8?Q?=E2=80=98waitpid=E2=80=99, _?= =?UTF-8?Q?=E2=80=98system*=E2=80=99, ?= etc. in service code can cause deadlocks Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Thu, 21 Jul 2022 15:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56674 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Maxime Devos Cc: 56674@debbugs.gnu.org Received: via spool by 56674-submit@debbugs.gnu.org id=B56674.16584179911140 (code B ref 56674); Thu, 21 Jul 2022 15:40:02 +0000 Received: (at 56674) by debbugs.gnu.org; 21 Jul 2022 15:39:51 +0000 Received: from localhost ([127.0.0.1]:38692 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oEYHG-0000IK-VS for submit@debbugs.gnu.org; Thu, 21 Jul 2022 11:39:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37768) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oEYHE-0000I6-0v for 56674@debbugs.gnu.org; Thu, 21 Jul 2022 11:39:49 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:53504) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEYH8-0003gP-An; Thu, 21 Jul 2022 11:39:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=Ymmz0FaKrODIrDTxxzCnC661qUdLGt8gJR7LCuNeBKc=; b=KkSClf0enQoWCzu4o88G 5AdkVFjAovuyOmb9LU4IqwT3gCoJA3dOUl2ohlfpKTClTJRXuZMDRPc9knD/tNg363SLYkxbL/qfs b0mxaQ7YvcUNo+KvowKHcBGImtWLJcFvHlQPV22WrLIEZOmXKvR7GVLq1e6Qwr82Z3SuVEBMbZAw4 IwGGp8uyHqVT1lEBKiZ2qD+chcZZygA6d9zksv560qPKu4AXpe9yUvuhhUezOs5WOwYjDVLXdy79s scx2UxIKMTqv9frYyFKOLD4Ngnzmg4P9mrX6m78Lnk6YmGJRwrJERi1Eb88Idov4hZO23KXmfpv99 BrXaXGoW2yCEOA==; Received: from [2001:660:6102:320:e120:2c8f:8909:cdfe] (port=34508 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEYH7-0003am-UH; Thu, 21 Jul 2022 11:39:42 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <8735evpipv.fsf@inria.fr> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Tridi 3 Thermidor an 230 de la =?UTF-8?Q?R=C3=A9volution, ?= jour du Melon X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Thu, 21 Jul 2022 17:39:39 +0200 In-Reply-To: (Maxime Devos's message of "Thu, 21 Jul 2022 01:48:02 +0200") Message-ID: <87fsiujwzo.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1658418139; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=Ymmz0FaKrODIrDTxxzCnC661qUdLGt8gJR7LCuNeBKc=; b=sMt4A3go8T5chq39W6EQID3O7Ee1J7Zo+cpnc7s6+OO0GwLkgXEkmNg+XBQuTcHhQf3O6h toAyM96Qkjf0nR7TH9JTNN3FDv/Cio4zJ61yThRxYPhR8SBiW2zwTlWZHm03KB1hmoMJce B+N9atOmCNmTLN2yAxWEL4eOdVLYtX3aWrogtFGybW4eFd8+IGKUoWHM9EIJQ7N1jhOeho 7lu4yQlbW48Z3IBtarr4po+E3R0jk7qrlZ510p+9/76i+UDVpcV5s9Sx7IutCNXoymLf5k V9OwGAmzvz1u79/Eh/d7X2VNZ3yMlFLfYHpb+BrMi1SgBvFMAZWgQ+Bl9NhrEA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1658418139; a=rsa-sha256; cv=none; b=IADelq+2rQMCJhaubDMt34WOfH8KlP2Z2SgnPyEXfLMGD6deAPYbD6PGJXynJhxnfcpqTQ xVzDFR/FE2FrzVheJJFFV5w4SxKBxLz7Y5AMboxmPUB7snn04TPe6dJjJrqE1UnwLmSs+m dZP6xvKG0VFl4Nep0+08bEA1N6QIpEwk7zrKx9yfVm8jMGVhna2x9dtfRymih+XyP9lyju Tql7+MNhshCLwXmsc3Vw1zE3AU2TVAzQ1DipmH8UT7MECgfBt0bzHE+vV016oecXwhM/46 RpG7bGkx5L4S+R4nYlpfphDaiKidHjTj/edYkDUbbvQQheYLQwjGoQaf4BIKWw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=KkSClf0e; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.84 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=KkSClf0e; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 7C2963D7D1 X-Spam-Score: -3.84 X-Migadu-Scanner: scn0.migadu.com X-TUID: QtMHym56Ph1M Maxime Devos skribis: > Why Shepherd and not guile fibers? Is this a Shepherd-specific problem? Blocking calls are a problem for Fibers in general, and =E2=80=98waitpid=E2= =80=99 is no exception. The problem here is Shepherd-specific in the sense that we=E2=80=99re more likely to use =E2=80=98system*=E2=80=99 and =E2=80=98waitpid=E2=80=99 in th= is context. It=E2=80=99s also Shepherd-specific because shepherd already runs an event loop that tracks signal FDs and will thus =E2=80=9Csee=E2=80=9D SIGCHLD events. > 3. Make waitpid (or a variant that does what we need) interact well > with guile-fibers, like how 'accept' is doesn't inhibit switching to > another fiber. There some Linux API with signal handlers or pid fds or > such that might be useful here, though I don't recall the > name. Presumably something similar can be done for the Hurd, though > some C glue may be needed to access the right Hurd APIs if the signal > handler API isn't portable. Yes, that=E2=80=99s roughly what I had in mind when I mentioned providing a replacement for =E2=80=98system*=E2=80=99 (but you=E2=80=99re right, it=E2= =80=99s a replacement for =E2=80=98waitpid=E2=80=99 at its core). > Alternatively: > > 4. Do the waitpid in a separate thread (needs work-around for the > multi-threaded fork problem, probably C things? Or modifying Guile and > maybe glibc to avoid async-unsafe things or make more things > async-safe or whatever the appropriate ...-safe is here.) For shepherd, multithreading is not an option due to the semantics of fork in the presence of threads. Ludo=E2=80=99.