Re: ERROR: Endless loop when referencing a slot

From: Clifford Beshers <beshers_at_cs.columbia.edu>
Date: Wed, 6 Nov 1996 13:35:51 -0500 (EST)

   Date: Wed, 06 Nov 1996 00:24:42 +0100
   From: Gerald Klix <gklix_at_fred.hassler.net>

   I it is possible to send STk in an endless loop
   when it is referencing a slot.
   Just execute the following program:

   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   ;;
   ;; This throws STk in an endless loop.
   ;;
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   (define-class <tc0> ()
     ((my-slot :init-keyword :slot)))

   (format #t "OK 1.~%")

   (let ((dummy (make <tc0> :slot 'shit)))
     (format #t "OK 2.~%")
     (eval
      '(define tv0
         (begin
           (eval '(define tv1 1) (the-environment))
           0))
      (the-environment))
     (format #t "Before loop.~%")
     (slot-ref dummy 'my-slot)
     (format #t "Never get here.~%")
     dummy)

   Where can I look into the sources to fix this bug.

   Gerald Klix

It doesn't send my STk into an infinite loop, but it does cause it to
fail with:

    *** Error:
    slot-ref: bad instance: 1

Your funky eval statements seem to modify the local environment,
rather than adding to it. I executed this modification:

    (define-class <tc0> ()
      ((my-slot :init-keyword :slot)))

    (format #t "OK 1.~%")

    (let ((dummy (make <tc0> :slot 'shit)))
      (format #t "OK 2.~%")
      (format #t "\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n");
      (display (environment->list (the-environment)))
      (format #t "\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n");
      (eval
       '(define tv0
          (begin
            (eval '(define tv1 1) (the-environment))
            0))
       (the-environment))
      (format #t "Before loop.~%")
      (format #t "\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n");
      (display (environment->list (the-environment)))
      (format #t "\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n");
      (slot-ref dummy 'my-slot)
      (format #t "Never get here.~%")
      dummy)

In the output of the first environment display, dummy has an expected
value:

    (((dummy . #[<tc0> 40020fcc])) ...

After the evals, the environment looks kind of strange:

    (((dummy . 1) (tv0 . 0))

Somehow, dummy gets set to the value of tv1. This certainly seems
like a bug to me. The fact that I get one error and you get an
infinite loop suggests to me that there is some memory that is not
initialized properly.

Cliff

-- 
Clifford Beshers                     Computer Graphics and User Interfaces Lab
beshers_at_cs.columbia.edu                         Department of Computer Science
http://www.cs.columbia.edu/~beshers                        Columbia University
Received on Wed Nov 06 1996 - 19:35:30 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST