unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Jeremy Phelps <jeremyphelps077@gmail.com>
Cc: 59540@debbugs.gnu.org
Subject: bug#59540: Calling length on a very long improper list is disastrous.
Date: Sat, 10 Dec 2022 18:27:50 +0100	[thread overview]
Message-ID: <87r0x7419l.fsf@gnu.org> (raw)
In-Reply-To: <CA+-17hVg390gZHxD7LmAO62oTFmH6mT8zq6MOyGCYSsi1aKWdw@mail.gmail.com> (Jeremy Phelps's message of "Thu, 24 Nov 2022 05:52:51 -0500")

Hi Jeremy,

Jeremy Phelps <jeremyphelps077@gmail.com> 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 (= 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.

I think there are several issues here:

  1. ‘length’ takes time linear to the size of the list (for
     non-circular lists).  That’s how it’s specified in the Scheme
     reports.

  2. Guile doesn’t truncate arguments that come after the “Wrong type
     argument” 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’m not sure we want to enable it by default on
wrong-type-arg error messages.

Thoughts?

Ludo’.





  reply	other threads:[~2022-12-10 17:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-24 10:52 bug#59540: Calling length on a very long improper list is disastrous Jeremy Phelps
2022-12-10 17:27 ` Ludovic Courtès [this message]
2022-12-12  9:25   ` lloda
2022-12-12 11:45     ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r0x7419l.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=59540@debbugs.gnu.org \
    --cc=jeremyphelps077@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).