From unknown Mon Aug 18 02:45:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59540: Calling length on a very long improper list is disastrous. Resent-From: Jeremy Phelps Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Thu, 24 Nov 2022 11:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 59540 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: 59540@debbugs.gnu.org X-Debbugs-Original-To: bug-guile@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.166928795728129 (code B ref -1); Thu, 24 Nov 2022 11:06:02 +0000 Received: (at submit) by debbugs.gnu.org; 24 Nov 2022 11:05:57 +0000 Received: from localhost ([127.0.0.1]:57491 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oyA3I-0007Jc-R1 for submit@debbugs.gnu.org; Thu, 24 Nov 2022 06:05:57 -0500 Received: from lists.gnu.org ([209.51.188.17]:50820) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oy9qr-0006z8-5W for submit@debbugs.gnu.org; Thu, 24 Nov 2022 05:53:05 -0500 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 1oy9qr-0004s0-0h for bug-guile@gnu.org; Thu, 24 Nov 2022 05:53:05 -0500 Received: from mail-vs1-xe30.google.com ([2607:f8b0:4864:20::e30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oy9qp-00084e-En for bug-guile@gnu.org; Thu, 24 Nov 2022 05:53:04 -0500 Received: by mail-vs1-xe30.google.com with SMTP id g65so834067vsc.11 for ; Thu, 24 Nov 2022 02:53:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=9sa10AxaTMSt1dxwoUOONP/31QAeGUPrPBUtG2B/xpc=; b=JpGSsoa7iatsebIoqpcuFAaOIiWe72WSE0XGBisET/e8RBZdMhG9wWyKXwnQnVjKEH w7uCB0TzFAQX+jdqWmNcOEk15CFjOKiacKSGAiQGT1QjuMK9rRrK/s4+ox/bxhgqGRw3 J41dulbKqc/Q8NxYyCRrBNE5al2SkUjLYIMr+VDdmHy3SbUNXza/aNUqFmV6G6h+XMvF xdpXVeJ4Tv/1bFaCM8NKFSyOoGP9CuY5VMpPY6IOxIl40vQwzw7T2Y8S/aODs9fqt/gr 2UfJDdLE0A/1ZXVDwNIhVvLZVdsitbpxGgm63xHSQ8JPxLpUCBH73n+UvAA7ytICNOcE /NAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=9sa10AxaTMSt1dxwoUOONP/31QAeGUPrPBUtG2B/xpc=; b=dYxSXF6BV1wfB3A6DaUIN2KvdoAx8LWPChrJr+bnvS0C4kAxoQK0lmU3HbRd9jUxRE 74ayvDDFuaCHX6dfjqf3wodrZCiw/VmFJjLAYKgz1tFzyVph3SKZtjbqhREhNIFSYt7G McajjUo6aiwtMebotsthb2rO1w4bJE1A+2FJUh8I1LF4vJacFHW9MuIeo3+TZpNuweVC S33gzTv5zdDi0vo0zuu0Ve9Dqeo7a54eUJNjfsIrnGLdEmffiB4tXtF5ap+XyqVRbr7d HTJ1DWmqloqfkhol/qsBnPYecA5Ybk+Dn4Iwn+RZC8gTHMVIhoET01/ZRPn9qVqjQDpk Sp2g== X-Gm-Message-State: ANoB5pkFuqQWYqhI+25MofXSYgIF3KaJK/iykMUlbYkLCiJ7X209tgMR XlfIQgPOerCV6jdnOkfxvuu0Zq8+wfSHLH7RzcjWAkac X-Google-Smtp-Source: AA0mqf4maAlmrQ83F92UQF9MfIvHLtN+c9EtQgGfeE4tYfcbmZi4d0a78x49E9rZDU7Cpy6oolaNURqGbhVfXwtmyUM= X-Received: by 2002:a05:6102:2906:b0:3a6:5c53:ba22 with SMTP id cz6-20020a056102290600b003a65c53ba22mr6861130vsb.82.1669287182372; Thu, 24 Nov 2022 02:53:02 -0800 (PST) MIME-Version: 1.0 From: Jeremy Phelps Date: Thu, 24 Nov 2022 05:52:51 -0500 Message-ID: Content-Type: multipart/alternative; boundary="00000000000088939d05ee3535be" Received-SPF: pass client-ip=2607:f8b0:4864:20::e30; envelope-from=jeremyphelps077@gmail.com; helo=mail-vs1-xe30.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.1 (-) X-Mailman-Approved-At: Thu, 24 Nov 2022 06:05:55 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) --00000000000088939d05ee3535be Content-Type: text/plain; charset="UTF-8" I lost my Emacs session today because I accidentally called the length function on an extremely long improper list. But Guile prints the entire thing when it reports the error that happens when the length function gets to the improper part of the list. It tried to print a few million elements just to tell me which list wasn't a proper list. To reproduce the error should be easy: (length (let loop ((result 'x) (n 50000000)) (if (= n 0) result (loop (cons n result) (- n 1))))) Emacs is more sensitive to the problem because it doesn't throw away any of the output. It's also really bad over SSH. The above test is enough to dump output to a local terminal for a minute or two, or to uninterruptibly tie up an SSH session for several minutes. --00000000000088939d05ee3535be Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I lost my Emacs session today because I accidentally calle= d the length function on an extremely long = improper list.=C2=A0

But Guile prints the entire thing w= hen it=C2=A0reports the error that happens when the length function gets to= the improper part of the list. It tried to print a few million elements ju= st to tell me which list wasn't a proper list.=C2=A0

To reproduce the error should be easy:

(length
=C2=A0 = =C2=A0(let loop ((result 'x)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (n 50000000))
=C2=A0 =C2=A0 =C2=A0(if (=3D n 0)<= /div>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0resu= lt
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0(loop (cons n result) (- n 1)))))

=
Emacs is more sensitive to the problem because it doesn't throw aw= ay any of the output. It's also really bad over SSH. The above test is = enough to dump output to a local terminal for a minute or two,=C2=A0or to u= ninterruptibly tie up an SSH session for several minutes.

--00000000000088939d05ee3535be-- From unknown Mon Aug 18 02:45:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59540: Calling length on a very long improper list is disastrous. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sat, 10 Dec 2022 17:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59540 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Jeremy Phelps Cc: 59540@debbugs.gnu.org Received: via spool by 59540-submit@debbugs.gnu.org id=B59540.16706932804886 (code B ref 59540); Sat, 10 Dec 2022 17:28:01 +0000 Received: (at 59540) by debbugs.gnu.org; 10 Dec 2022 17:28:00 +0000 Received: from localhost ([127.0.0.1]:44070 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p43dn-0001Gk-Sg for submit@debbugs.gnu.org; Sat, 10 Dec 2022 12:28:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51494) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p43dm-0001Ga-KW for 59540@debbugs.gnu.org; Sat, 10 Dec 2022 12:27:59 -0500 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 1p43dh-00088b-8k; Sat, 10 Dec 2022 12:27:53 -0500 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=aFOKGrZGMdFje+Za2nCsQB40GZbB/pgwgrLPrZnCizs=; b=IgNXe8H5MsVcc8LvsA5+ 7hJ/JBV5ziRmoxun4U150j7aiBp51tjdrlkkzURDJVvZaDlVEoAxIseVORVJ25TSHzzVYGZXu7gb3 TuThtuDmSw43M+fBF18C7N5hDOMJ00iCyBRmik4YVpEcfJE2hRtgN4D2I5ZPJUX9iwLfpoKenCe2G 0JfSY8PBA5bc8Wa156gmZ6hSRfqfUjXhbOv1+gb+rJ7rCKS0qZrPBWPjrfWa/iZXr9PXSqkpjM0uh ZnwpqtIb2CzLJHaTLEah8y5HTZnszQA0TQ+A1Uta1qMD/+eMlaqYpAUx2iPzru/NEslVDDnS6RLpP MsysK76JMioL7Q==; 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 1p43dg-0008HT-Nv; Sat, 10 Dec 2022 12:27:52 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: Date: Sat, 10 Dec 2022 18:27:50 +0100 In-Reply-To: (Jeremy Phelps's message of "Thu, 24 Nov 2022 05:52:51 -0500") Message-ID: <87r0x7419l.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi Jeremy, Jeremy Phelps skribis: > I lost my Emacs session today because I accidentally called the length > function on an extremely long improper list. > > But Guile prints the entire thing when it reports the error that happens > when the length function gets to the improper part of the list. It tried = to > print a few million elements just to tell me which list wasn't a proper > list. > > To reproduce the error should be easy: > > (length > > (let loop ((result 'x) > > (n 50000000)) > > (if (=3D n 0) > > result > > (loop (cons n result) (- n 1))))) > > > Emacs is more sensitive to the problem because it doesn't throw away any = of > the output. It's also really bad over SSH. The above test is enough to du= mp > output to a local terminal for a minute or two, or to uninterruptibly tie > up an SSH session for several minutes. I think there are several issues here: 1. =E2=80=98length=E2=80=99 takes time linear to the size of the list (for non-circular lists). That=E2=80=99s how it=E2=80=99s specified in the= Scheme reports. 2. Guile doesn=E2=80=99t truncate arguments that come after the =E2=80=9C= Wrong type argument=E2=80=9D error message. 3. Emacs poorly handles very long lines, to put it mildly. Of these only #2 is something we could work on. However, truncation has proven to be a hindrance sometimes (in backtraces, objects are automatically), so I=E2=80=99m not sure we want to enable it by default on wrong-type-arg error messages. Thoughts? Ludo=E2=80=99. From unknown Mon Aug 18 02:45:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59540: Calling length on a very long improper list is disastrous. Resent-From: lloda Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Mon, 12 Dec 2022 09:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59540 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: Jeremy Phelps , 59540@debbugs.gnu.org Received: via spool by 59540-submit@debbugs.gnu.org id=B59540.167083715329426 (code B ref 59540); Mon, 12 Dec 2022 09:26:01 +0000 Received: (at 59540) by debbugs.gnu.org; 12 Dec 2022 09:25:53 +0000 Received: from localhost ([127.0.0.1]:51717 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4f4L-0007eY-Dz for submit@debbugs.gnu.org; Mon, 12 Dec 2022 04:25:53 -0500 Received: from mta-12-4.privateemail.com ([198.54.127.107]:1059) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4f4K-0007eN-9M for 59540@debbugs.gnu.org; Mon, 12 Dec 2022 04:25:52 -0500 Received: from mta-12.privateemail.com (localhost [127.0.0.1]) by mta-12.privateemail.com (Postfix) with ESMTP id 390B718000A1; Mon, 12 Dec 2022 04:25:45 -0500 (EST) Received: from [192.168.1.105] (unknown [51.154.167.214]) by mta-12.privateemail.com (Postfix) with ESMTPA id 5768A18000A2; Mon, 12 Dec 2022 04:25:42 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) From: lloda In-Reply-To: <87r0x7419l.fsf@gnu.org> Date: Mon, 12 Dec 2022 10:25:39 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <602C3A2B-D6B0-42F2-8E50-7A9E581A9879@sarc.name> References: <87r0x7419l.fsf@gnu.org> X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On 10 Dec 2022, at 18:27, Ludovic Court=C3=A8s wrote: >=20 > ... > Of these only #2 is something we could work on. However, truncation = has > proven to be a hindrance sometimes (in backtraces, objects are > automatically), so I=E2=80=99m not sure we want to enable it by = default on > wrong-type-arg error messages. >=20 > Thoughts? >=20 > Ludo=E2=80=99. There's previous discussion on this, going both ways. I think excessive output is a more serious problem, because it should be = possible to go to a backtrace frame and look at objects directly. On the = other hand, it should also be possible to C-c when guile starts to flood = the terminal. But neither of these workarounds is reliable :-/ = Ultimately this printing should be configurable. We already have the repl-option system (repl-option-set! repl 'print = ...). This system doesn't apply to exception messages nor backtraces. I = think if it did, that would mostly solve the problem. I also think that, besides options to truncate or not, we should have a = pager (display at most a page, give options to next/stop/all). That = would be the best default. From unknown Mon Aug 18 02:45:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59540: Calling length on a very long improper list is disastrous. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Mon, 12 Dec 2022 11:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59540 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: lloda Cc: Jeremy Phelps , 59540@debbugs.gnu.org Received: via spool by 59540-submit@debbugs.gnu.org id=B59540.16708455243372 (code B ref 59540); Mon, 12 Dec 2022 11:46:01 +0000 Received: (at 59540) by debbugs.gnu.org; 12 Dec 2022 11:45:24 +0000 Received: from localhost ([127.0.0.1]:52434 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4hFL-0000sK-Oe for submit@debbugs.gnu.org; Mon, 12 Dec 2022 06:45:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45504) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4hFL-0000sE-1n for 59540@debbugs.gnu.org; Mon, 12 Dec 2022 06:45:23 -0500 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 1p4hFF-00047q-8B; Mon, 12 Dec 2022 06:45:17 -0500 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=Caj+SYfqKODrvhxWaBHqfjLgC2sNAMJK88mNLidXBwY=; b=lKKAe02LuZKRV5fYQdu8 RHpcOXBBgN5Pwg4fr6wDfnCCaWtLoYao53eMV1/CmjL5fuGyh5UI/h9qcq5b+XmuFzkxUWXw85jN1 dxLRaJWotIu0Tl1DP3t3hVisSwvHZiHl5wL0kf2/2Sk1/I2G5iETKazkT9vyX2vRMsar0yqmRJbGF T8B5KR4q1ja4RJCs2ALRRghOout3L5eCFOYfj99bWdlDDtGFKLN9/aaZTOqaSBpoba/5vUP/aqVke 9VGHjglbj1yE6ULc6NutyE57hVWUJ46bBPu8j6YhMRtC7ptlXzVx00qjpmYSSlSQjfJJkgdQhtE9K oiP0KcdTHtNmnQ==; Received: from [89.207.171.77] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p4hF9-0008GT-O8; Mon, 12 Dec 2022 06:45:16 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <87r0x7419l.fsf@gnu.org> <602C3A2B-D6B0-42F2-8E50-7A9E581A9879@sarc.name> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Duodi 22 Frimaire an 231 de la =?UTF-8?Q?R=C3=A9volution,?= jour de la =?UTF-8?Q?Bruy=C3=A8re?= 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: Mon, 12 Dec 2022 12:45:08 +0100 In-Reply-To: <602C3A2B-D6B0-42F2-8E50-7A9E581A9879@sarc.name> (lloda@sarc.name's message of "Mon, 12 Dec 2022 10:25:39 +0100") Message-ID: <87sfhk26d7.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, lloda skribis: > I think excessive output is a more serious problem, because it should be = possible to go to a backtrace frame and look at objects directly. On the ot= her hand, it should also be possible to C-c when guile starts to flood the = terminal. But neither of these workarounds is reliable :-/ Ultimately this = printing should be configurable. > > We already have the repl-option system (repl-option-set! repl 'print ...)= . This system doesn't apply to exception messages nor backtraces. I think i= f it did, that would mostly solve the problem. Yes. Right now it=E2=80=99s just $COLUMNS; we should have a documented SRF= I-39 parameter for that. > I also think that, besides options to truncate or not, we should have a p= ager (display at most a page, give options to next/stop/all). That would be= the best default. Yes! Ludo=E2=80=99.