From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id +JtUHEu6lWAezwAAgWs5BA (envelope-from ) for ; Sat, 08 May 2021 00:08:11 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id aHYOGEu6lWCUOgAA1q6Kng (envelope-from ) for ; Fri, 07 May 2021 22:08:11 +0000 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 CAC341DF10 for ; Sat, 8 May 2021 00:08:10 +0200 (CEST) Received: from localhost ([::1]:48326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lf8dk-000353-QD for larch@yhetil.org; Fri, 07 May 2021 18:08:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lf8dd-00034f-Vs for bug-guix@gnu.org; Fri, 07 May 2021 18:08:01 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:34662) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lf8dd-0003zT-Ol for bug-guix@gnu.org; Fri, 07 May 2021 18:08:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lf8dd-000417-J1 for bug-guix@gnu.org; Fri, 07 May 2021 18:08:01 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#41948: Shepherd deadlocks Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 07 May 2021 22:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41948 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Mathieu Othacehe Received: via spool by 41948-submit@debbugs.gnu.org id=B41948.162042524915431 (code B ref 41948); Fri, 07 May 2021 22:08:01 +0000 Received: (at 41948) by debbugs.gnu.org; 7 May 2021 22:07:29 +0000 Received: from localhost ([127.0.0.1]:46206 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lf8d7-00040p-3s for submit@debbugs.gnu.org; Fri, 07 May 2021 18:07:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60738) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lf8d5-00040i-Se for 41948@debbugs.gnu.org; Fri, 07 May 2021 18:07:28 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:45636) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lf8d0-0003a1-NU for 41948@debbugs.gnu.org; Fri, 07 May 2021 18:07:22 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=58758 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lf8d0-0001LJ-8x; Fri, 07 May 2021 18:07:22 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <87h7v75txx.fsf@gnu.org> <87a70yc9kj.fsf@gnu.org> <87k0xyhq22.fsf@gnu.org> <87v97u9pu1.fsf@gnu.org> Date: Sat, 08 May 2021 00:07:20 +0200 In-Reply-To: <87v97u9pu1.fsf@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Fri, 07 May 2021 23:49:42 +0200") Message-ID: <87o8dm9p0n.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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: , Cc: 41948@debbugs.gnu.org Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1620425291; 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: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; bh=0W1xPSbyk7M1uuTlDQheUJ3Mm4WymWr+dmnwTU/b0i4=; b=NVrZLePtczieownWRZoxhAg2+Ih63KX8Z0WIppj37ubuZ6BVXjU/2bRfWpRj4OUHflbMlb 1+FeSjd7l45a0ABfEeKYLNI2a31692nJWcnC8W/fSvYIteCHAgEhhiIdBj4M3PGVzxunE+ Y43bhRgE6T16UxmGVh9z/pntgy1rMlm2dVUU4tpT0hfm3lDEnD17Ifyc2cpG/qmc9CNp+p E4Ut3NscedcES9StlwsoURf0d/K8Sgz8AmyPNI4Yn7cRplFCNIuC/F7jXDJS0ymAhLAUle f60nKRDh6yRMdMbvVbi+E+pEM+0Eb9tgjiVhcWdPHrRx8e7en+8OczyBm7wf3A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1620425291; a=rsa-sha256; cv=none; b=ELRuMJQmjiq7oJ7aZmsgFUOj1TeugMUcHP9sINetwXxz7+IfwuJItr1kxmk3QLpp0cZflt Q+v/NourELSB9qAfRnfIm4e+Me9lmTnHT+44tSr+twJWGndO67FXH5euT7PpWJHTbUKDJF vtkJQ5lwWQt4BZq51zWMJAyy6YaQMAMGnXgj09e862MFTouVAX5CDCjVDYGAmhVgw0VwYp p3eZENCJGQgTY57botseqlrqDVb+Xt5jeJu9BXU58VH3ahBS/xiK+8GmVQNupb4mi/V3Zq UpfacVdn1G0GD1dzBtujdolF06NE1/hgqNljAssSZquf2Zds0FMdXH5Rc6yxxg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Spam-Score: -2.95 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Queue-Id: CAC341DF10 X-Spam-Score: -2.95 X-Migadu-Scanner: scn0.migadu.com X-TUID: g4EbeGWqff/4 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s skribis: > While working on a fix for this issue (finalizer pipe shared between > parent and child process), I found the =E2=80=98sleep_pipe=E2=80=99 of th= e main thread > is also shared between the parent and its child. Here=E2=80=99s a patch that fixes the problem as exposed by the reproducer. Thoughts? (We=E2=80=99d need these pipes to be =E2=80=9CO_CLOFORK=E2=80=9D rather tha= n O_CLOEXEC.) Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/libguile/posix.c b/libguile/posix.c index eaf12de32..e0c157c20 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1217,6 +1217,29 @@ SCM_DEFINE (scm_execle, "execle", 2, 0, 1, #undef FUNC_NAME #ifdef HAVE_FORK +static void * +do_fork (void *ret) +{ + pid_t pid = fork (); + + if (pid == 0) + { + /* The child process must not share its sleep pipe with the + parent. */ + int err; + scm_thread *t = SCM_I_CURRENT_THREAD; + + close (t->sleep_pipe[0]); + close (t->sleep_pipe[1]); + err = pipe2 (t->sleep_pipe, O_CLOEXEC); + if (err != 0) + abort (); + } + + * (pid_t *) ret = pid; + return NULL; +} + SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0, (), "Creates a new \"child\" process by duplicating the current \"parent\" process.\n" @@ -1244,7 +1267,9 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0, " further behavior unspecified. See \"Processes\" in the\n" " manual, for more information.\n"), scm_current_warning_port ()); - pid = fork (); + + scm_without_guile (do_fork, &pid); + if (pid == -1) SCM_SYSERROR; return scm_from_int (pid); --=-=-=--