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

%stack-block wierdness



I discovered that the following code will crash my Mac after executing
n times (the value of n varies)

(%stack-block ((p 16))
    (mapcar #'(lambda (i) (%put-long p i i) (%get-long p i)) '(0 1 2 3)))

I then discoverd that the docs on %stack-block warn against closing off
the variables it creates. I can see why this is dangerous, but I don't
see why the above code crashes the machine. All my uses of the closed off
variable are within its creating %stack-block.

To check things out further, I wrote a version that prints out the original
pointer and then in the #'(lambda... prints out the closed off pointer
value as mapping occurs. The values matched - so I still can't fathom why
the code crashes my Mac.

The following variation does work:

(defun foo (p)
  (mapcan #'(lambda (i) (%put-long p i i) (list (%get-long p i))) '(0 1 2 3)))

(%stack-block ((p 16))
  (foo p))

As far as I can tell, this won't crash my Mac. Is it really safe?

-ME