[Openmcl-devel] need some help with "Unhandled exception"

Ron Garret ron at flownet.com
Sat Dec 28 13:06:41 PST 2013


You have an infinite loop in your macroexpansion:

? (macroexpand-all '(ancestor ?x a))
> Error: Stack overflow on value stack.

Also, I have no idea what this code is intended to do, but whatever it is this almost certainly isn’t helping:

? (pprint (macroexpand '(ancestor ?x a)))

(LET ((?X '?X) (?Y 'A))
  (DECLARE (SPECIAL ?X ?Y))
  (IF (VAR? ?X) (MAKUNBOUND ?X))
  (IF (VAR? ?Y) (MAKUNBOUND ?Y))
  (UNION (SELECT-LOOP (P ?X ?Y) COLLECT IT)
         (SELECT-LOOP (P ?X ?Z) APPEND (ANCESTOR ?Z ?Y))))

You are binding ?X to itself, and then immediately making it unbound again.  That is almost certainly not what you want to do.

rg


On Dec 28, 2013, at 12:05 PM, Taoufik Dachraoui <dachraoui.taoufik at gmail.com> wrote:

> Hi
> 
> Could you please check this "Unhandled exception" and explain what is wrong
> with my code
> 
> (defun var? (x)
>   (and (symbolp x) (not (keywordp x)) (eq (char (symbol-name x) 0) #\?)))
> 
> (defun vars-in (expr)
>   (if (atom expr)
>       (if (var? expr) (list expr))
>       (union
>        (vars-in (car expr))
>        (vars-in (cdr expr)))))
> 
> (defmacro aif (test-form then-form &optional else-form)
>   `(let ((it ,test-form))
>      (if it ,then-form ,else-form)))
> 
> (defun select! (pat) ; returns a list of bindings
>   (print pat)
>   '((it . (p b a)) (?x . 'b)))
> 
> (defmacro select-loop (pat &rest keywords-and-forms)
>   (let ((bind (gensym))
>         (vars (cons 'it (vars-in pat))))
>     `(block select-loop
>        (aif (select! ',pat)
>             (progn
>               (let ((binds it) ,@(mapcar #'list vars))
>                 (declare (special , at vars))
>                 (loop for ,bind in binds
>                    do (progn
>                         (setf it (cdr (assoc 'it ,bind)))
>                         ,@(mapcar #'(lambda (v) `(setf ,v (cdr (assoc ',v ,bind))))
>                                   vars))
>                      , at keywords-and-forms)))))))
> 
> (defmacro defrule (name args &rest body)
>   `(defmacro ,name ,args
>      (list 'let (list ,@(mapcar #'(lambda (x) `(list ',x `',,x)) args))
>        '(declare (special , at args))
>        ,@(mapcar #'(lambda (x) `'(if (var? ,x) (makunbound ,x))) args)
>        ,@(mapcar #'(lambda (x) `',x) body))))
> 
> (defrule ancestor (?x ?y)
>   (union
>    (select-loop (p ?x ?y) collect it)
>    (select-loop (p ?x ?z)
>                 append (ancestor ?z ?y))))
> 
> ? (ancestor ?x a)
> 
> Unhandled exception 10 at 0x28545, context->regs at #xb01641fc
> Exception occurred while executing foreign code
>  at compact_dynamic_heap + 965
> received signal 10; faulting address: 0xd360000                                                                                                                                 
> ? for help
> [3422] Clozure CL kernel debugger: ?
> (G)  Set specified GPR to new value
> (R)  Show raw GPR/SPR register values
> (L)  Show Lisp values of tagged registers
> (F)  Show FPU registers
> (S)  Find and describe symbol matching specified name
> (B)  Show backtrace
> (T)  Show info about current thread
> (M)  Show memory areas
> (X)  Exit from this debugger, asserting that any exception was handled
> (P)  Propagate the exception to another handler (debugger or OS)
> (K)  Kill Clozure CL process
> (V)  Show Subversion revision information
> (?)  Show this help
> [3422] Clozure CL kernel debugger: B
> current thread: tcr = 0x2000f0, native thread ID = 0xbe03, interrupts enabled
> 
> 
> Bogus frame 606b40
> [3422] Clozure CL kernel debugger: L
> [3422] Clozure CL kernel debugger:
> 
> 
> Kind regards
> Taoufik
> 
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel




More information about the Openmcl-devel mailing list