Subject: [clisp-list] Bug Report: clisp eats whole memory

From: Will Newton <[email-masked]>
Date: Sat Jun 15 09:45:05 2002

Reported via Debian BTS:

Received: (at submit) by bugs.debian.org; 3 Jun 2002 16:16:16 +0000
>From [email-masked] Mon Jun 03 11:16:16 2002
18:14:53 +0200
Date: Mon, 3 Jun 2002 17:50:09 +0200
From: Jan Gregor <[email-masked]>
To: Debian Bug Tracking System <[email-masked]>
Subject: clisp eats whole memory
Reply-To: [email-masked]

--T4sUOijqQbZv57TR
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Package: clisp
Version: 1:2.27-0.5
Severity: important

Following sequence produce this effect:
  (jtms-init)
  (setq a (install-node 'a))
  (setq b (install-node 'b))
  (install-just a (list b))

I found that this problem has something to do with push and defstruct.
In harlequin lisp (lispworks) program worked without problems.
When I replaced defstruct with defclass, problem disappeared in clisp
too.

-- System Information
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux pisidlo 2.2.20 #1 Sun Feb 24 20:26:35 CET 2002 i686
Locale: LANG=cs_CZ, LC_CTYPE=cs_CZ

Versions of packages clisp depends on:
ii  libc6                    2.2.5-4         GNU C Library: Shared libraries 
an
ii  libncurses5              5.2.20020112a-7 Shared libraries for terminal 
hand

--T4sUOijqQbZv57TR
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="jtms.lsp"

(defstruct node
  (index 0)
  (datum nil)
  (label 'out)
  (support nil)
  (justifications nil)
  (consequences nil)
)  

(defstruct justification
  (index 0)
  in-list
  out-list
  consequence
)

(defvar *node-counter*)
(defvar *just-counter*)

(defun in-node? (node) (eq (node-label node) 'in))

(defun out-node? (node) (eq (node-label node) 'out))

(defun jtms-init ()
  (setq *node-counter* 0
        *just-counter* 0)
)

(defun install-node (datum)
  (let (node)
    (setq node (make-node :datum datum :index (incf *node-counter*)))
))

(defun install-just (conseq in-supp &optional (out-supp nil))
  (let (just)
    (setq just (make-justification :index (incf *just-counter*)
                                   :in-list in-supp
                                   :out-list out-supp
                                   :consequence conseq))
;  (setf (node-justifications conseq)
;       (append (node-justifications conseq) just))
    (push just (node-justifications conseq))
    just
))

--T4sUOijqQbZv57TR--

---

From: Sam Steingold <[email-masked]>
Date: Sat Jun 15 10:15:03 2002

> * In message <[email-masked]>
> * On the subject of "[clisp-list] Bug Report: clisp eats whole memory"
> * Sent on Sat, 15 Jun 2002 17:47:50 +0100
> * Honorable Will Newton <[email-masked]> writes:
>
> Reported via Debian BTS:
> 
> Package: clisp
> Version: 1:2.27-0.5
> Severity: important
> 

this creates a circular structure which cannot be printed without
*print-circle* being set to T (since ANSI CL mandates the #S readable
format for the structure output).
*print-circle* is NIL initially as per the ANSI CL spec.

(setq *print-circle* t)
and try again - it will work.

> In harlequin lisp (lispworks) program worked without problems.  When I
> replaced defstruct with defclass, problem disappeared in clisp too.

CLOS classes are not printed readably (as per the spec), so they can be
printed even without *print-circle* == T.

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.2 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
Don't ascribe to malice what can be adequately explained by stupidity.