From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id BQxNHWKFUWRgkgAASxT56A (envelope-from ) for ; Tue, 02 May 2023 23:49:22 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 2FlSHGKFUWQHJAEAauVa8A (envelope-from ) for ; Tue, 02 May 2023 23:49:22 +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 02D6D1AF0E for ; Tue, 2 May 2023 23:49:22 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ptxs2-0008AG-Sf; Tue, 02 May 2023 17:49:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ptxrr-000882-E6 for bug-guix@gnu.org; Tue, 02 May 2023 17:49:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ptxrr-00039M-5T for bug-guix@gnu.org; Tue, 02 May 2023 17:49:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ptxrr-0004xs-1Z for bug-guix@gnu.org; Tue, 02 May 2023 17:49:03 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#63024: Crash during `guix import pypi -r' Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 02 May 2023 21:49:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63024 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Greg Hogan Cc: 63024@debbugs.gnu.org, 62334@debbugs.gnu.org, Josselin Poiret , Simon Tournier Received: via spool by 63024-submit@debbugs.gnu.org id=B63024.168306411719035 (code B ref 63024); Tue, 02 May 2023 21:49:03 +0000 Received: (at 63024) by debbugs.gnu.org; 2 May 2023 21:48:37 +0000 Received: from localhost ([127.0.0.1]:45222 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ptxrQ-0004wv-JM for submit@debbugs.gnu.org; Tue, 02 May 2023 17:48:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53460) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ptxrP-0004wV-5E; Tue, 02 May 2023 17:48:35 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ptxrJ-00035U-Tx; Tue, 02 May 2023 17:48:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=03mEDkqHutfu+ZEJiWGkHrV+Y0B1e8fzbCdUb8NoRJ4=; b=SAwPrgE2Ie5050JF5Z7v pYXCw7SPlYKABXhwJa2YlYr9g6CvmlNUkuQfZ/fdsW8gTmf4kd8s/z2g099enlr0OC5XO/DG/DjtQ rvba1xNi5dolyqd4bD2d1T7rR8V/9HH+xb8E2gody4x57nDGf8tFbyDstIrhBBmJ/LtFGPL1NTVSg DAf4NY9C6QlnKg+cYvkRcE6v9gmj+MZIYMU3nttjsIpprlXpYKQbSqKy7UdnJYK6r+x891YlyAPEs G8iuyFCx4HzDvipnjkZHi5xjzeToHspaNEIIAooIKXuyl3ybVDHBhIV7eoMkpnt7Fno6AwCrHPlcW LNAZprN892OQbA==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ptxrJ-0004Pg-4M; Tue, 02 May 2023 17:48:29 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= In-Reply-To: (Greg Hogan's message of "Tue, 21 Mar 2023 10:17:22 -0400") References: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Date: Tue, 02 May 2023 23:48:26 +0200 Message-ID: <87fs8e5rrp.fsf@gnu.org> 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1683064162; a=rsa-sha256; cv=none; b=D7VllGwNBSAdrTGksE5kiMi5U0T70UrpUNunqETTxhkIek1jCx/p+qCEGgrh3rMLVYyJfB +X9qe3YMhPmPm4yLqd0hPde9OQDQ+Wm2OrgTzcZDumLXEUPN4CUVTqyyJH7c6GFYIWJHEe yCyHu3Q333+Kg1/1pjB4wPgy7AAWO0EBWOAC6UxhCYYClS5LKd7+MuwtIDX5GgKqJadx3M o7uZl6FNjEIFnIkghYQFxq+QhDvDBkd4x0FwZw+dS/hF7UCk5i4ByMMnP20QEKk3DZveLe ybT4nEveumgAhioIBv950ef7ufkNLivykWhRJcdV8/bm+PzLAkop8TLcJxLsGQ== 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=SAwPrgE2; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1683064162; 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=03mEDkqHutfu+ZEJiWGkHrV+Y0B1e8fzbCdUb8NoRJ4=; b=dihZffVNYoiOUbvsAUQP0+CrqbruGxZddAYEYXXO7V4bcxEI/eS4vj3w+loXj0CTeTtSgL 9arwLRjtj1b1xenww9gmRCL06KsvyMU8H4i5cg1I7QtXASrs+sQVky+5nzFG5QrqPtrVic 7FOWJOLSnq6SyybS6jUJ3e5DW1HhJN/cPC4DRTMsVDKAhtPwzDyQIrzc5Y6pqn1n8F5kfD n8KrBQHIdNwH7iDnxrmTCp4u1OcE5oWqLAqWxjiWWxB8Uz/dEMtjQ6Nj6ethsZw5IvmS6x ltZuahSpUov7eJPBCQ2ap6E/GSdZ3GAF7nUhwbx3aCeC1acw1KKCzDaEieXCcg== X-Migadu-Spam-Score: -1.91 X-Spam-Score: -1.91 X-Migadu-Queue-Id: 02D6D1AF0E X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=SAwPrgE2; 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-TUID: EK4nq6FEOBZ0 Hello! Greg Hogan skribis: > Starting download of /tmp/guix-file.xReGb4 >>>From https://web.archive.org/web/20230321140958/https://files.pythonhoste= d.org/packages/49/01/21337857631a97ab551bb2e3b5691ed6b1b9586011aa6a5355b969= 4a37fa/demon-2.0.6.tar.gz... > In procedure connect*: Connection timed out I can very much reproduce the bug with =E2=80=9Cguix import pypi -r cdlib= =E2=80=9D on 39ba8a10971f15264966823e8696d63c2995df86 and thereabouts. Turns out it=E2=80=99s a fun story! (Josselin, I=E2=80=99m sure you=E2=80=99ll love = it.) First, the person who wrote =E2=80=98connect*=E2=80=99 *cough* hadn=E2=80= =99t carefully read the Guile manual, which reads (info "(guile) Ports and File Descriptors"): Note that =E2=80=98select=E2=80=99 may return early for other reasons, fo= r example due to pending interrupts. Clearly, =E2=80=98select=E2=80=99 is returning early, so we should check th= at and loop. So far, so good. Now, why is =E2=80=98select=E2=80=99 returning immediately? Because the un= derlying select(2) call is passed an extra file descriptor, the =E2=80=9Csleep pipe= =E2=80=9D, as you can see in =E2=80=98scm_std_select=E2=80=99 in libguile, and it=E2=80= =99s that file descriptor, number 3, that=E2=80=99s active at each select(2) call: --8<---------------cut here---------------start------------->8--- 28825 23:06:04 pselect6(15, [3], [14], [14], {tv_sec=3D10, tv_nsec=3D0}, NU= LL) =3D 1 (in [3], left {tv_sec=3D9, tv_nsec=3D999991063}) <0.000079> 28825 23:06:04 read(3, "A", 1) =3D 1 <0.000044> --8<---------------cut here---------------end--------------->8--- Why so much activity on that =E2=80=9Csleep pipe=E2=80=9D, you ask? Well, = once we=E2=80=99ve filtered the read(3, =E2=80=A6) calls, a pattern appears: --8<---------------cut here---------------start------------->8--- 14335:28825 23:06:04 read(3, "A", 1) =3D 1 <0.000044> 14344:28825 23:06:04 read(3, "r", 1) =3D 1 <0.000121> 14353:28825 23:06:04 read(3, "c", 1) =3D 1 <0.000107> 14362:28825 23:06:04 read(3, "h", 1) =3D 1 <0.000040> 14436:28825 23:06:04 read(3, "i", 1) =3D 1 <0.000049> 14445:28825 23:06:04 read(3, "v", 1) =3D 1 <0.000029> 14454:28825 23:06:04 read(3, "e", 1) =3D 1 <0.000019> 14463:28825 23:06:04 read(3, ":", 1) =3D 1 <0.000017> 14472:28825 23:06:04 read(3, " ", 1) =3D 1 <0.000019> 14481:28825 23:06:04 read(3, " ", 1) =3D 1 <0.000020> 14490:28825 23:06:04 read(3, "/", 1) =3D 1 <0.000019> 14499:28825 23:06:04 read(3, "t", 1) =3D 1 <0.000015> 14508:28825 23:06:04 read(3, "m", 1) =3D 1 <0.000018> 15001:28825 23:06:04 read(3, "p", 1) =3D 1 <0.000015> 15010:28825 23:06:04 read(3, "/", 1) =3D 1 <0.000016> 15019:28825 23:06:04 read(3, "g", 1) =3D 1 <0.000016> 15028:28825 23:06:04 read(3, "u", 1) =3D 1 <0.000015> 15037:28825 23:06:04 read(3, "i", 1) =3D 1 <0.000015> 15046:28825 23:06:04 read(3, "x", 1) =3D 1 <0.000015> 15055:28825 23:06:04 read(3, "-", 1) =3D 1 <0.000015> --8<---------------cut here---------------end--------------->8--- See? Who=E2=80=99s chatting over our sleep pipe? --8<---------------cut here---------------start------------->8--- 4806:28831 23:06:03 dup2(0, 3) =3D 3 <0.000011> 4807:28831 23:06:03 dup2(3, 0) =3D 0 <0.000011> 4808:28831 23:06:03 dup2(4, 1) =3D 1 <0.000012> 4809:28831 23:06:03 dup2(5, 2) =3D 2 <0.000010> 4810:28831 23:06:03 close(3) =3D 0 <0.000010> 4811:28831 23:06:03 close(4) =3D 0 <0.000011> 4812:28831 23:06:03 close(5) =3D 0 <0.000010> 4813:28831 23:06:03 close(6) =3D 0 <0.000010> 4814:28831 23:06:03 close(7) =3D 0 <0.000010> 4815:28831 23:06:03 close(8) =3D 0 <0.000011> 4816:28831 23:06:03 close(9) =3D 0 <0.000010> 4817:28831 23:06:03 close(10) =3D 0 <0.000010> 4818:28831 23:06:03 close(11) =3D 0 <0.000011> 4819:28831 23:06:03 close(12) =3D 0 <0.000010> 4820:28831 23:06:03 close(13) =3D 0 <0.000010> 4821:28831 23:06:03 close(14) =3D 0 <0.000011> 4822:28831 23:06:03 close(15) =3D -1 EBADF (Bad file desc= riptor) <0.000011> 4823:28831 23:06:03 prlimit64(0, RLIMIT_NOFILE, NULL, {rlim_cur=3D1024, = rlim_max=3D4*1024}) =3D 0 <0.000011> 4824:28831 23:06:03 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) =3D 0 <0.00= 0010> 4825:28831 23:06:03 execve("/home/ludo/src/guix/scripts/unzip", ["unzip"= , "/tmp/guix-file.bmholm", "-d", "/tmp/guix-directory.Ok2DAA", "cdlib-0.2.6= .dist-info/METADATA"], 0x18a7db0 /* 85 v [=E2=80=A6] 4938:28831 23:06:03 write(1, "Archive: /tmp/guix-file.bmholm\n", 32) = =3D 32 <0.000018> --8<---------------cut here---------------end--------------->8--- =E2=80=98unzip=E2=80=99! And all its friends invoked from (guix import pyp= i): --8<---------------cut here---------------start------------->8--- (call-with-temporary-directory (lambda (dir) (parameterize ((current-error-port (%make-void-port "rw+")) (current-output-port (%make-void-port "rw+"))) (if (string=3D? "zip" (file-extension source-url)) (invoke "unzip" archive "-d" dir) (invoke "tar" "xf" archive "-C" dir))) =E2=80=A6)) --8<---------------cut here---------------end--------------->8--- Looks like we shoudn=E2=80=99t dup(4, 1) in the child process, because 4 is= the other end of our sleep pipe. :-) The problem exists both in 3.0.9 and Guile =E2=80=98main=E2=80=99. Looks r= elated to the file descriptor shuffling code in =E2=80=98do_spawn=E2=80=99. WDYT, Jossel= in? Ludo=E2=80=99.