GNU bug report logs -
#30626
26.0.91; Crash when traversing a `stream-of-directory-files'
Previous Next
Reported by: Michael Heerdegen <michael_heerdegen <at> web.de>
Date: Tue, 27 Feb 2018 09:23:01 UTC
Severity: normal
Tags: fixed, patch
Found in version 26.0.91
Done: Noam Postavsky <npostavs <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #98 received at 30626 <at> debbugs.gnu.org (full text, mbox):
Michael Heerdegen <michael_heerdegen <at> web.de> writes:
> #+begin_src emacs-lisp
> ;; -*- lexical-binding: t -*-
>
> (require 'stream)
>
> (let ((stream (stream-range 1 1000000)))
> (while (not (stream-empty-p stream))
> (cl-callf stream-rest stream)))
> #+end_src
>
> This is semantically exactly like test2.el, only the call to
> `stream-flush' has been replaced by literally writing out the
> definition. Nonetheless, the compiled file suddenly doesn't crash Emacs
> when loaded. Loading the uncompiled file test3.el still crashes.
Aha, but the following also crashes, whether compiled or not:
;; -*- lexical-binding: t -*-
(require 'stream)
(let* ((stream0 (stream-range 1 1000000))
(stream stream0))
(while (not (stream-empty-p stream))
(cl-callf stream-rest stream)))
So the problem is that the initial stream0 object can reach the entire
unfolding stream as it goes, and just holding on to that reference is
enough to keep the whole thing in memory.
Now, I can see that letting stream0 automagically get access to the
unfolded result can be an optimization in some cases, although in this
case it's a pessimization. It could also affect the semantics if
unfolding the stream has side effects, not sure if stream.el makes
guarantees about that though.
This bug report was last modified 6 years and 45 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.