SapphireDensetsu / ypsilon

Automatically exported from code.google.com/p/ypsilon
Other
0 stars 0 forks source link

continuations messed up #100

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Try the following script:

#!r6rs
(import (rnrs) (rnrs mutable-strings))

(define (->string x len)
  (define n 0)
  (define str (make-string len))
  (call/cc
    (lambda (k)
      (define p
        (make-custom-textual-output-port
          "*limited-port*"
          (lambda (buf i count)
            (let f ([i i] [count count])
              (unless (zero? count)
                (if (= n len)
                    (k str)
                    (begin
                      (string-set! str n (string-ref buf i))
                      (set! n (+ n 1))
                      (f (+ i 1) (- count 1))))))
            count)
          #f #f #f))
      (write x p)
      (flush-output-port p)
      (substring str 0 n))))

(let ([data
       (let f ([n 20] [ac #t])
         (if (zero? n) ac (f (- n 1) (cons ac ac))))])
  (display (->string data 80))
  (newline))

I expect to see 

((((((((((((((((((((#t . #t) #t . #t) (#t . #t) #t . #t) ((#t . #t) #t . #t) (#t

once.  I see it a zillion times, followed by 
fatal: heap memory overflow (32MB)
[exit]

This is Ypsilon 0.9.6-update3 Copyright (c) 2008 Y.Fujita, LittleWing Company 
Limited.

Original issue reported on code.google.com by aghul...@gmail.com on 18 May 2009 at 7:47

GoogleCodeExporter commented 8 years ago
I have fixed bug in revision 458.
Thank you! :)
-- fujita

$ ypsilon --version
Ypsilon 0.9.6-trunk/r458 Copyright (c) 2009 Y.Fujita, LittleWing Company 
Limited.
$ ypsilon bugport.scm
((((((((((((((((((((#t . #t) #t . #t) (#t . #t) #t . #t) ((#t . #t) #t . #t) (#t
$ ypsilon --r6rs bugport.scm
((((((((((((((((((((#t . #t) #t . #t) (#t . #t) #t . #t) ((#t . #t) #t . #t) (#t

Original comment by y.fujita...@gmail.com on 18 May 2009 at 12:52