[Top][All Lists]

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

bug#30626: 26.0.91; Crash when traversing a `stream-of-directory-files'

From: Michael Heerdegen
Subject: bug#30626: 26.0.91; Crash when traversing a `stream-of-directory-files'
Date: Fri, 02 Mar 2018 14:04:53 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.91 (gnu/linux)

Michael Heerdegen <address@hidden> writes:

> Noam Postavsky <address@hidden> writes:
> > Maybe I've misunderstood, but is it not the case that iterating over
> > (stream-range 1 n) should require only a constant amount of memory,
> > regardless of the value of n?

But in this regard, we have a problem with how lexical-binding is
implemented for interpreted code.  Nested thunks (as implemented in
"thunk.el") accumulate useless variable bindings - e.g.

(defun test ()
        (lambda () 1))))))))
(#:val . #1#)
(#:forced . t)
(#:val . #1#)
(#:forced . t)
(#:val . #1#)
(#:forced . t)
nil 1)

The length of the variable list is equivalent to the number of thunk
wrappers.  I believe that these useless variable lists are responsible
for the crashes of the uncompiled versions of the test files I had
posted.  I think this problem is different from the gc issue.

Streams use nested thunks.  Of course does thunk.el not explicitly add
such variable lists to the result - this is how closures are built in
interpreted code.  For nested thunks these just add up.

BTW, if you byte-compile the above `test' function, then

(disassemble (test))
byte code:
  args: nil
0       constant  1
1       return

and this problem is gone.


reply via email to

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