chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] CHICKEN hang / crash / memoize egg


From: Andy Bennett
Subject: [Chicken-users] CHICKEN hang / crash / memoize egg
Date: Fri, 1 Apr 2016 15:28:26 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.7.0

Hi Peeps!

I'm running CHICKEN 4.9.0rc1 and I'm trying out the memoize egg.

I saw the tail-call-optimized version of the factorial procedure in the
memoize documentation at http://api.call-cc.org/doc/memoize and I've
been trying to modify it so that it memoizes intermediate results such
that, for example, a call to (fact 10) makes a subsequent call to (fact
9) fast.

In doing so I've managed to get the interpreter into a loop or crash it
entirely.


When pasting this into a csi prompt:

-----
(use numbers)
(use memoize)

(define (fact** x #!optional (self memo-fact**))
  (if (= x 0)
    1
    (* x (self (- x 1)))))

(define memo-fact** (memoize fact**))

(define x (time (memo-fact**  35710)))
(define x (time (memo-fact**  35720)))
(define x (time (memo-fact**  35730)))
-----

I get:

-----
$ csi

CHICKEN
(c) 2008-2014, The Chicken Team
(c) 2000-2007, Felix L. Winkelmann
Version 4.9.0rc1 (rev 3cf1967)
linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]
compiled 2014-04-17 on hd-t1179cl (Linux)

; loading /home/local/andyjpb/.csirc ...
; loading /usr/local/chicken-4.9.0/lib/chicken/7/parley.import.so ...
; loading /usr/local/chicken-4.9.0/lib/chicken/7/chicken.import.so ...
; loading
/usr/local/chicken-4.9.0/lib/chicken/7/data-structures.import.so ...
; loading /usr/local/chicken-4.9.0/lib/chicken/7/extras.import.so ...
; loading /usr/local/chicken-4.9.0/lib/chicken/7/ports.import.so ...
; loading /usr/local/chicken-4.9.0/lib/chicken/7/posix.import.so ...
; loading /usr/local/chicken-4.9.0/lib/chicken/7/srfi-1.import.so ...
; loading /usr/local/chicken-4.9.0/lib/chicken/7/srfi-13.import.so ...
; loading /usr/local/chicken-4.9.0/lib/chicken/7/srfi-18.import.so ...
; loading /usr/local/chicken-4.9.0/lib/chicken/7/stty.import.so ...
; loading /usr/local/chicken-4.9.0/lib/chicken/7/srfi-69.import.so ...
; loading /usr/local/chicken-4.9.0/lib/chicken/7/foreign.import.so ...
; loading /usr/local/chicken-4.9.0/lib/chicken/7/foreigners.import.so ...
; loading /usr/local/chicken-4.9.0/lib/chicken/7/parley.so ...
; loading /usr/local/chicken-4.9.0/lib/chicken/7/stty.so ...
#;1> (use numbers)
; loading /usr/local/chicken-4.9.0/lib/chicken/7/numbers.import.so ...
; loading /usr/local/chicken-4.9.0/lib/chicken/7/numbers.so ...
#;2> (use memoize)
#;2>
#;2> (define (fact** x #!optional (self memo-fact**))
#;2>   (if (= x 0)
#;2>     1
#;2>     (* x (self (- x 1)))))
#;2>
#;2> (define memo-fact** (memoize fact**))
#;2>
#;2> (define x (time (memo-fact**  35710)))
#;2> (define x (time (memo-fact**  35720)))
#;2> (define x (time (memo-fact**  35730)))
#;2>
; loading /usr/local/chicken-4.9.0/lib/chicken/7/memoize.import.so ...
; loading /usr/local/chicken-4.9.0/lib/chicken/7/memoize.so ...

Note: the following toplevel variables are referenced but unbound:

  memo-fact** (in fact**)
2.804s CPU time, 1.064s GC time (major), 81305 mutations, 21/1551 GCs
(major/minor)
0s CPU time, 20 mutations
0s CPU time, 20 mutations
#;8>
[panic] out of memory - heap full while resizing - execution terminated

...more...
parley.scm:610: history817818
parley.scm:610: history817818
parley.scm:603: ##sys#dynamic-wind
parley.scm:603: history798799
parley.scm:603: history798799
parley.scm:603: history798799
parley.scm:603: history798799
parley.scm:610: ##sys#dynamic-wind
parley.scm:610: history817818
parley.scm:610: history817818
parley.scm:615: get-next-char!
parley.scm:579: parley-char-ready?
parley.scm:586: append-while-incomplete
parley.scm:560: string-null?
parley.scm:561: repl-prompt
parley.scm:561: g769    <--
-----

Sometimes I'll crash immediately and someytimes I have to press some
keys when the "#;8>" prompt appears.


If I run the above script thusly:

-----
$ csi -s memo-demo.scm
-----

I see

-----
$ csi -s ../memo-demo.scm
2.908s CPU time, 1.164s GC time (major), 75257 mutations, 22/1550 GCs
(major/minor)
0s CPU time, 20 mutations
-----

...and it hangs there (on the last time call) indefinitely using all the
CPU. Ctrl-C doesn't terminate it: a call to 'killall csi' does tho'.


If you cannot reproduce it then try varying the numbers in the call to
memo-fact**.



Is this a known bug in Chicken 4.9.0rc1 or the srfi-69 hash-tables that
memoize uses?


Thanks for any tips you can offer.




Regards,
@ndy

-- 
address@hidden
http://www.ashurst.eu.org/
0290 DA75 E982 7D99 A51F  E46A 387A 7695 7EBA 75FF




reply via email to

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