I met a problem the other day with some buggy code of
mine involving loop and tail-recursion. Here's the
> (load "~/code/lisp/delme.lisp")
;; Loading file /cygdrive/c/home/code/lisp/delme.lisp ...
;; Loaded file /cygdrive/c/home/code/lisp/delme.lisp
...compile the function trace-outline...
> (compiled-function-p #'trace-outline)
> (trace-outline '(115 41))
*** - Program stack overflow. RESET
*** - Internal error: statement in file "debug.d", line
1149 has been
Please send the authors of the program a
description how you produced
I can usually, but not always continue working after this.
CYGWIN_NT-5.1 mb6596 1.5.21(0.156/4/2) 2006-07-30 14:21
"2.39 (2006-07-16) (built 3367203258) (memory 3367203785)"
I have been able to reproduce this on a similar
pre-built cygwin clisp setup and without the full
linking set (all the same version). Here's the file I
used. Note that the code is *BUGGY*, and I have since
rewrote it to get the code to run. For context, I
provide that here. It was a quick hack to create an
ordered linked list of points around the boundary of an
image object, like chain codes.
(defparameter *coords* (list))
;; This works.
(defun trace-outline (start-coord)
(flet ((valid-step (c)
(and (= (apply #'aref *image* c) 1)
(not (equal (cadr *coords*) c)))))
(push start-coord *coords*)
for (row col) = (car *coords*)
for c in `((,(1- row) ,col) (,(1+ row) ,col)
(,row ,(1- col)) (,row ,(1+ col)))
when (valid-step c)
(push c *coords*)
until (equal start-coord (car *coords*)))))
PS: It is not convenient to change the data *rows* or
*cols*, and since they're so small, it didn't matter -
I'm sending them verbatim. Additionally, using a global
counter, I counted more than 8000 iterations in the
loop tail-function-call bit before the stack error.
Please tell if I've screwed up anywhere, or missed out
anything. Thanks in advance.
Log in to post a comment.