unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#59021: Unbounded heap growth when combining dynamic states & delimited continuation
@ 2022-11-04 18:24 Ludovic Courtès
  2022-11-05 22:04 ` Ludovic Courtès
  2022-11-07 16:03 ` Maxim Cournoyer
  0 siblings, 2 replies; 5+ messages in thread
From: Ludovic Courtès @ 2022-11-04 18:24 UTC (permalink / raw)
  To: 59021

(This is a followup to <https://github.com/wingo/fibers/issues/65>,
itself a followup to <https://issues.guix.gnu.org/58631>.)

Consider this code:

--8<---------------cut here---------------start------------->8---
;; https://issues.guix.gnu.org/58631
;; https://github.com/wingo/fibers/issues/65

(define loss
  (make-vector 1000000))

(let ((tag (make-prompt-tag "my prompt")))
  (define handler
    (lambda (k i)
      (when (zero? (modulo i 2000000))
        (pk 'heap-size (assoc-ref (gc-stats) 'heap-size)))

      (call-with-prompt tag
        (lambda ()
          (k (modulo (+ 1 i) 10000000)))
        handler)))

  (call-with-prompt tag
    (let ((state (current-dynamic-state)))
      (lambda ()
        ;; (define (with-dynamic-state state thunk)
        ;;   (let ((previous #f))
        ;;     (dynamic-wind
        ;;       (lambda () (set! previous (set-current-dynamic-state state)))
        ;;       thunk
        ;;       (lambda () (set-current-dynamic-state previous)))))
        (with-dynamic-state state
                            (lambda ()
                              (let loop ((i 0))
                                (loop (abort-to-prompt tag i)))))))
    handler))
--8<---------------cut here---------------end--------------->8---

On Guile 3.0.8, this program exhibits seemingly unbounded heap growth.
Uncommenting the local ‘with-dynamic-state’ definition fixes the
problem.

Ludo’.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-11-20 17:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-04 18:24 bug#59021: Unbounded heap growth when combining dynamic states & delimited continuation Ludovic Courtès
2022-11-05 22:04 ` Ludovic Courtès
2022-11-20 17:28   ` Ludovic Courtès
2022-11-07 16:03 ` Maxim Cournoyer
2022-11-07 21:52   ` Maxim Cournoyer

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).