Re: core dump in mapcan+sort?

Gary King <[email protected]> Wed, 26 Apr 2006 13:31:19 -0400
Newsgroups gmane.lisp.allegro
Message-ID <[email protected]>
Hi David,

FWIW, I have duplicated the behavior you describe. The error I get is:

(ERROR SYNCHRONOUS-OPERATING-SYSTEM-SIGNAL :NAME ...)

The code works as expected in OpenMCL (1.0) and SBCL 0.9.11

Also, the folllowing two versions are OK:

> (flet ((GETY ()
>          (sort (copy-list '(0 1)) #'<)))
>
>   (defun bar ()
>     (mapcan #'(lambda (x)
>                 (mapcar #'(lambda (y) (cons x y))
>                         (gety)))
>             '(a b))))
>
>
> (defun baz ()
>   (mapcan #'(lambda (x)
>               (mapcar #'(lambda (y) (cons x y))
>                       (sort (copy-list '(0 1)) #'<)))
>           '(a b)))

but this one still fails:

> (labels ((GETY ()
>            (sort (copy-list '(0 1)) #'less))
>          (LESS (a b)
>            (< a b)))
>
>     (defun boo ()
>       (mapcan #'(lambda (x)
>                   (mapcar #'(lambda (y) (cons x y))
>                           (gety)))
>               '(a b))))

and this one succeeds:

> (labels ((GETY ()
>            (sort (copy-list '(0 1)) (lambda (a b) (< a b)))))
>
>     (defun boo-2 ()
>       (mapcan #'(lambda (x)
>                   (mapcar #'(lambda (y) (cons x y))
>                           (gety)))
>               '(a b))))


HTH,



On Apr 26, 2006, at 12:36 PM, David Tolpin wrote:

> Hi,
>
> if you save in a file, compile and load the following:
>
> (flet ((LESS (a b)
>          (< a b)))
>
>   (flet ((GETY ()
>            (sort (copy-list '(0 1)) #'less)))
>
>     (defun FOO ()
>       (mapcan #'(lambda (x)
>                   (mapcar #'(lambda (y) (cons x y))
>                           (gety)))
>               '(a b)))))
>
> and then execute (foo) in REPL, ALISP hangs, reports illegal  
> instruction or dumps core. Is it something simple I don't see? The  
> code works with Lispworks. I've checked the code with ACL 8.0 on  
> Mac OS X/PPC, Mac OS X/Intel and ACL 7.0 (trial) on FreeBSD.
>
> David Tolpin
>
>
> -- 
>


-- 
Gary Warren King
metabang.com
http://www.metabang.com/
(413) 210 7511
gwking on #lisp (occasionally)