[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#59540: Calling length on a very long improper list is disastrous.

From: Ludovic Courtès
Subject: bug#59540: Calling length on a very long improper list is disastrous.
Date: Sat, 10 Dec 2022 18:27:50 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)

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

  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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]