GNU bug report logs - #57095
'terminal-window-size' throws ENOTTY ("Inappropriate ioctl for device")

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix; Severity: important; Reported by: Csepp <raingloom@HIDDEN>; dated Tue, 9 Aug 2022 23:13:02 UTC; Maintainer for guix is bug-guix@HIDDEN.
Severity set to 'important' from 'normal' Request was from Ludovic Courtès <ludo@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 57095 <at> debbugs.gnu.org:


Received: (at 57095) by debbugs.gnu.org; 10 Aug 2022 14:53:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Aug 10 10:53:41 2022
Received: from localhost ([127.0.0.1]:50435 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oLn5Y-0002Dv-DZ
	for submit <at> debbugs.gnu.org; Wed, 10 Aug 2022 10:53:40 -0400
Received: from eggs.gnu.org ([209.51.188.92]:35950)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1oLn5W-0002Dh-IN
 for 57095 <at> debbugs.gnu.org; Wed, 10 Aug 2022 10:53:39 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:35104)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1oLn5Q-0004jm-Ln; Wed, 10 Aug 2022 10:53:32 -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=FkICelX0t0ZI2LIspmlBj45LCZim4KGtzLMBHZRz/Gs=; b=ZgBBPmGBNcwkzTIHu5cz
 BdTk7LgkQoHO1S9OoXox6I+LEu3hYV+78zGPc4wQbgJBAge1jbzNdbmxgZY2Zuwn0mgdWhu2coSCj
 00hrmZeoIJKLE3sL+izknJlm53ZHlTdKdf4ivn3Tf6t7wgvtzBjD5ssjMpqiwuHyM/svtBMMBYltb
 LsNdT9XgqsIPPlvgb4EU/HsVdvmV0DyLpOSfrfhYjdjBZLW5ZfGCqM+whbMYYr/4ZxWhXaOo+/6e+
 PjLKm9q6nZDBwaGZ2JJE2OypI2x8LbjBVzRNi6zFrbMU9pt7ZGCzGfSlR4uu0cEjvF6w44hSc4yni
 Z4x2hfRaSG5CrQ==;
Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:51654
 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1oLn5Q-0001cb-9Y; Wed, 10 Aug 2022 10:53:32 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Josselin Poiret <dev@HIDDEN>
Subject: Re: bug#57095: another "inappropriate ioctl" bug :)
References: <874jylf1v8.fsf@HIDDEN> <87bkssjjt5.fsf@HIDDEN>
Date: Wed, 10 Aug 2022 16:53:29 +0200
In-Reply-To: <87bkssjjt5.fsf@HIDDEN> (Josselin Poiret's message of "Wed, 
 10 Aug 2022 15:43:18 +0200")
Message-ID: <87lerwywt2.fsf@HIDDEN>
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-Spam-Score: -0.3 (/)
X-Debbugs-Envelope-To: 57095
Cc: 57095 <at> debbugs.gnu.org, Csepp <raingloom@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.3 (-)

Hi!

Josselin Poiret <dev@HIDDEN> skribis:

> We also use a big wrapping `with-error-handling` to display errors
> properly in the case when they are not caught.  The difference is that
> `with-error-handling` adds a non-unwinding handler, while catch is
> unwinding.  My first thought was that non-unwinding handlers, even outer
> ones would get priority over unwinding ones, since once the stack's
> unwound you can't really go back (I have no idea if that last part is
> actually true).  In practice this is actually false, I tested with a
> very simple example, but that lead me to test by setting `#:unwind? #t`
> for the `guard*` definition in guix/ui.scm and the issue went away, so I'm
> clueless as to why this happens.  What seems weird is that the error is
> not caught at all!

The inner handler, even if it=E2=80=99s unwinding and the outer one is not,
appears to have higher precedence:

--8<---------------cut here---------------start------------->8---
scheme@(guix read-print)> (with-exception-handler (lambda args (pk 'outer a=
rgs))
			    (lambda ()
			      (with-exception-handler
				  (lambda args (pk 'inner args))
				(lambda()
				  (rmdir "/"))
				#:unwind? #t))
			    #:unwind? #f)

;;; (inner (#<&compound-exception components: (#<&external-error> #<&origin=
 origin: "rmdir"> #<&message message: "~A"> #<&irritants irritants: ("Devic=
e or resource busy")> #<&exception-with-kind-and-args kind: system-error ar=
gs: ("rmdir" "~A" ("Device or resource busy") (16))>)>))
$17 =3D (#<&compound-exception components: (#<&external-error> #<&origin or=
igin: "rmdir"> #<&message message: "~A"> #<&irritants irritants: ("Device o=
r resource busy")> #<&exception-with-kind-and-args kind: system-error args:=
 ("rmdir" "~A" ("Device or resource busy") (16))>)>)
scheme@(guix read-print)> (with-exception-handler (lambda args (pk 'outer a=
rgs))
			    (lambda ()
			      (catch 'system-error
				(lambda ()
				  (rmdir "/"))
				(lambda args
				  (pk 'inner args))))
			    #:unwind? #f)

;;; (inner (system-error "rmdir" "~A" ("Device or resource busy") (16)))
$18 =3D (system-error "rmdir" "~A" ("Device or resource busy") (16))
--8<---------------cut here---------------end--------------->8---

This appears to work:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,use(guix build syscalls)
scheme@(guile-user)> (terminal-columns)
$19 =3D 119
scheme@(guile-user)> ,use(guix ui)
scheme@(guile-user)> (with-error-handling (terminal-columns))
$20 =3D 119
scheme@(guile-user)> (terminal-columns (open-input-string ""))
$21 =3D 143
scheme@(guile-user)> (with-error-handling (terminal-columns (open-input-str=
ing "")))
$22 =3D 143
--8<---------------cut here---------------end--------------->8---

Needs more investigation=E2=80=A6

Ludo=E2=80=99.




Information forwarded to bug-guix@HIDDEN:
bug#57095; Package guix. Full text available.

Message received at 57095 <at> debbugs.gnu.org:


Received: (at 57095) by debbugs.gnu.org; 10 Aug 2022 13:43:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Aug 10 09:43:32 2022
Received: from localhost ([127.0.0.1]:46958 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oLlzg-0005s7-6r
	for submit <at> debbugs.gnu.org; Wed, 10 Aug 2022 09:43:32 -0400
Received: from jpoiret.xyz ([206.189.101.64]:41836)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dev@HIDDEN>) id 1oLlzV-0005ro-K4
 for 57095 <at> debbugs.gnu.org; Wed, 10 Aug 2022 09:43:31 -0400
Received: from authenticated-user (jpoiret.xyz [206.189.101.64])
 by jpoiret.xyz (Postfix) with ESMTPA id A93F5184F2C;
 Wed, 10 Aug 2022 13:43:19 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim;
 t=1660139000;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type:
 in-reply-to:in-reply-to:references:references;
 bh=esvlO3QoUIJTDhuQjFlJx7ghQb7/btOOknAxZ+lJHHg=;
 b=P2xj+Wm7yrWNvWpP0Zi6x6D4Rzrs+90H3KS0+v9BLiRrcXBJXQ86wqCLwr/d1Dv9Lxr+36
 ElQywRNRjYtLR6EEVNUEhNKAbn43NfLsW04zTE+Z2hiZ+C9kY8XwxJFwOWBFDjppDsMKPF
 RevJAObF0NGhA1R5eJ2eR4oZ4YxSWeI06uLV0Y0GtOiIBmap8hw7AhGnHB8SGKn8m6dym2
 m2bQf4+Q9COsEque4vMXO2+yOhnjvGfYVangVxMuagX5732vCqGIzhOlGP1udGi/qV69tA
 yowTyIs63/CskSRHjGEJAzj20svML1NRe6EZASsg9QQh/7C2bPEPOcTl1J7rCQ==
From: Josselin Poiret <dev@HIDDEN>
To: Csepp <raingloom@HIDDEN>, 57095 <at> debbugs.gnu.org
Subject: Re: bug#57095: another "inappropriate ioctl" bug :)
In-Reply-To: <874jylf1v8.fsf@HIDDEN>
References: <874jylf1v8.fsf@HIDDEN>
Date: Wed, 10 Aug 2022 15:43:18 +0200
Message-ID: <87bkssjjt5.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Authentication-Results: jpoiret.xyz;
 auth=pass smtp.auth=jpoiret@HIDDEN smtp.mailfrom=dev@HIDDEN
X-Spamd-Bar: /
X-Spam-Score: 2.0 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview: Hi! Csepp <raingloom@HIDDEN> writes: > ``` >
 ./pre-inst-env
 guix import pypi -r linode-cli | tee -a gnu/packages/python-xyz.scm > > ...
 > In guix/build/syscalls.scm: > 2284:35 1 (_) > 2273:8 0 (terminal-window-size
 _) > > guix/build/sysc [...] 
 Content analysis details:   (2.0 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 2.0 PDS_OTHER_BAD_TLD      Untrustworthy TLDs
 [URI: jpoiret.xyz (xyz)]
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 -0.0 SPF_PASS               SPF: sender matches SPF record
 0.0 FROM_SUSPICIOUS_NTLD   From abused NTLD
X-Debbugs-Envelope-To: 57095
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 2.0 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  Hi! Csepp <raingloom@HIDDEN> writes: > ``` > ./pre-inst-env
    guix import pypi -r linode-cli | tee -a gnu/packages/python-xyz.scm > > ...
    > In guix/build/syscalls.scm: > 2284:35 1 (_) > 2273:8 0 (terminal-window-size
    _) > > guix/build/sysc [...] 
 
 Content analysis details:   (2.0 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
  2.0 PDS_OTHER_BAD_TLD      Untrustworthy TLDs
                             [URI: jpoiret.xyz (xyz)]
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 -0.0 SPF_PASS               SPF: sender matches SPF record
  0.0 FROM_SUSPICIOUS_NTLD   From abused NTLD
  1.0 BULK_RE_SUSP_NTLD      Precedence bulk and RE: from a suspicious TLD
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager

Hi!

Csepp <raingloom@HIDDEN> writes:

> ```
> ./pre-inst-env guix import pypi -r linode-cli | tee -a gnu/packages/python-xyz.scm
>
> ...
> In guix/build/syscalls.scm:
>   2284:35  1 (_)
>    2273:8  0 (terminal-window-size _)
>
> guix/build/syscalls.scm:2273:8: In procedure terminal-window-size:
> In procedure terminal-window-size: Inappropriate ioctl for device
> ```
>
> I assume the progress bar code does not gracefully handle the very
> common case when stdout is not a terminal.

There is some code in place to handle this issue, and it works most of
the time, but not here.  The issue is that we handle any error coming
from ioctl by first throwing a `'system-error`, and handling it with a
`catch` that checks whether the errno is ENOTTY (and deprecated
equivalents) and in that case falls back to a good default.  In the case
where the error is not of that type, it is rethrown.  This works well in
most cases, but here comes the Guile shenanigans:

We also use a big wrapping `with-error-handling` to display errors
properly in the case when they are not caught.  The difference is that
`with-error-handling` adds a non-unwinding handler, while catch is
unwinding.  My first thought was that non-unwinding handlers, even outer
ones would get priority over unwinding ones, since once the stack's
unwound you can't really go back (I have no idea if that last part is
actually true).  In practice this is actually false, I tested with a
very simple example, but that lead me to test by setting `#:unwind? #t`
for the `guard*` definition in guix/ui.scm and the issue went away, so I'm
clueless as to why this happens.  What seems weird is that the error is
not caught at all!

Does anyone have a clue?

Best,
-- 
Josselin Poiret




Information forwarded to bug-guix@HIDDEN:
bug#57095; Package guix. Full text available.
Changed bug title to ''terminal-window-size' throws ENOTTY ("Inappropriate ioctl for device")' from 'another "inappropriate ioctl" bug :)' Request was from Ludovic Courtès <ludo@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 9 Aug 2022 23:12:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Aug 09 19:12:23 2022
Received: from localhost ([127.0.0.1]:45484 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oLYOd-0005s6-0t
	for submit <at> debbugs.gnu.org; Tue, 09 Aug 2022 19:12:23 -0400
Received: from lists.gnu.org ([209.51.188.17]:35572)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raingloom@HIDDEN>) id 1oLYOZ-0005rw-Pv
 for submit <at> debbugs.gnu.org; Tue, 09 Aug 2022 19:12:21 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:59084)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <raingloom@HIDDEN>)
 id 1oLYOZ-0002qC-Lj
 for bug-guix@HIDDEN; Tue, 09 Aug 2022 19:12:19 -0400
Received: from mx1.riseup.net ([198.252.153.129]:38374)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <raingloom@HIDDEN>)
 id 1oLYOX-0008JW-NW
 for bug-guix@HIDDEN; Tue, 09 Aug 2022 19:12:19 -0400
Received: from fews2.riseup.net (fews2-pn.riseup.net [10.0.1.84])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
 client-signature RSA-PSS (2048 bits) client-digest SHA256)
 (Client CN "mail.riseup.net", Issuer "R3" (not verified))
 by mx1.riseup.net (Postfix) with ESMTPS id 4M2TNw2jsYzDqCp
 for <bug-guix@HIDDEN>; Tue,  9 Aug 2022 23:12:16 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak;
 t=1660086736; bh=/ikHm0t0nDW8CU0Zum9eDx86AGQcVVpQwf3bHDtsf4A=;
 h=From:To:Subject:Date:From;
 b=ZrxQcIC73Vt+6GAUv3fT4ls4aK4OrzGdkUe5H4dkOf9gcSbdHQG5Khb9E5Y4mgHJP
 4g8pOhY9NfIjonGce/TIl4vttfbt8xSPebNoyUup3aZAJDHB1+iOTULWIaLQjOByfu
 UO5awvBncljZhBDotv26YbuSLadE5rJuOnAfxnk0=
X-Riseup-User-ID: 70D0B80CB337C70CEE558A8024D00F13340C6678EB46A22B8EFE33E8B2C3DD25
Received: from [127.0.0.1] (localhost [127.0.0.1])
 by fews2.riseup.net (Postfix) with ESMTPSA id 4M2TNv4V88z1yWd
 for <bug-guix@HIDDEN>; Tue,  9 Aug 2022 23:12:15 +0000 (UTC)
From: Csepp <raingloom@HIDDEN>
To: bug-guix@HIDDEN
Subject: another "inappropriate ioctl" bug :)
Date: Tue, 09 Aug 2022 23:06:11 +0000
Message-ID: <874jylf1v8.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=198.252.153.129;
 envelope-from=raingloom@HIDDEN; helo=mx1.riseup.net
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001,
 SPF_HELO_PASS=-0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)


```
./pre-inst-env guix import pypi -r linode-cli | tee -a gnu/packages/python-xyz.scm

...
In guix/build/syscalls.scm:
  2284:35  1 (_)
   2273:8  0 (terminal-window-size _)

guix/build/syscalls.scm:2273:8: In procedure terminal-window-size:
In procedure terminal-window-size: Inappropriate ioctl for device
```

I assume the progress bar code does not gracefully handle the very
common case when stdout is not a terminal.

Good thing I'm in a local checkout so I can just make it return some
constant.




Acknowledgement sent to Csepp <raingloom@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-guix@HIDDEN. Full text available.
Report forwarded to bug-guix@HIDDEN:
bug#57095; Package guix. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 29 Aug 2022 13:15:02 UTC

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