[cmucl-imp] Function with declared result type NIL returned.
G'day, I think there may be an issue with the way CMUCL handles return values. I'm having trouble developing a reduced test case so I have attached the code I encountered the issue with. The code relies on an external library titled external-program. I'm using cumcl-2016-06-x86-darwin. Thanks Mark ;; $ git clone https://github.com/sellout/external-program.git ;; $ cd external-program && git checkout 9f6d518 ;; $ cmucl -noinit -load issue.lisp ;; issue.lisp (in-package "CL-USER") (eval-when (:compile-toplevel :load-toplevel :execute) (require :asdf)) (eval-when (:compile-toplevel :load-toplevel :execute) (push (merge-pathnames "external-program/") asdf:*central-registry*) (asdf:load-system "external-program")) (defun test () (print (lisp-implementation-type)) (print (lisp-implementation-version)) (terpri) (external-program:start "/bin/ls" (list "-la") :output *standard-output*)) (unwind-protect (test) (uiop:quit)) ;; $ cmucl -noinit -load issue.lisp ;; "CMU Common Lisp" ;; "snapshot-2016-06 (21A Unicode)" ;; Function with declared result type NIL returned: ;; (PCL:FAST-METHOD EXTERNAL-PROGRAM:START (T T)) ;; [Condition of type KERNEL:SIMPLE-CONTROL-ERROR] ;; Restarts: ;; 0: [CONTINUE] Return NIL from load of "issue.lisp". ;; 1: [ABORT ] Skip remaining initializations. ;; Debug (type H for help) ;; ("LAMBDA (.KEYARGS-START. .VALID-KEYS. G3148)" #<unused-arg> #<unused-arg> ;; "/bin/ls" ("-la") ...) ;; Source: (FUNCALL (THE FUNCTION #'(PCL:FAST-METHOD EXTERNAL-PROGRAM:START #)) ;; (PCL::FAST-METHOD-CALL-PV-CELL #:G3148) ;; (PCL::FAST-METHOD-CALL-NEXT-METHOD-CALL #:G3148) ;; PCL::.ARG0. ;; ...) ;; 0] total 16 ;; drwxr-xr-x 5 hungry wheel 170 15 Jun 09:20 . ;; drwxrwxrwt 37 root wheel 1258 15 Jun 09:20 .. ;; -rw-r--r-- 1 hungry wheel 634 15 Jun 09:20 issue.lisp ;; drwxr-xr-x 8 hungry wheel 272 15 Jun 09:20 external-program
"Mark" == Mark Cox <markcox80@gmail.com> writes:
Mark> G'day, I think there may be an issue with the way CMUCL Mark> handles return values. Mark> I'm having trouble developing a reduced test case so I have Mark> attached the code I encountered the issue with. The code Mark> relies on an external library titled external-program. Thanks for the test case. I can reproduce this on my system as well. Based on the error message it seems as if external-program:start was declared not to return actually returned. That would seem to indicate an error in external-program not cmucl. But I'll look some more into this. It would be great if you could file an issue if you have an account. If not, don't worry about it. -- Ray
On Wed, Jun 15, 2016 at 1:20 PM, Raymond Toy <toy.raymond@gmail.com> wrote:
Based on the error message it seems as if external-program:start was declared not to return actually returned. That would seem to indicate an error in external-program not cmucl.
I can't find any proclamations, declamations, declarations or THE forms associated with the generic function external-program:start.
But I'll look some more into this.
Thanks.
It would be great if you could file an issue if you have an account. If not, don't worry about it.
Sure. https://gitlab.common-lisp.net/cmucl/cmucl/issues/23 Cheers Mark
"Raymond" == Raymond Toy <toy.raymond@gmail.com> writes:
"Mark" == Mark Cox <markcox80@gmail.com> writes: Mark> G'day, I think there may be an issue with the way CMUCL Mark> handles return values.
Mark> I'm having trouble developing a reduced test case so I have Mark> attached the code I encountered the issue with. The code Mark> relies on an external library titled external-program. Raymond> Thanks for the test case. I can reproduce this on my Raymond> system as well. Raymond> Based on the error message it seems as if Raymond> external-program:start was declared not to return Raymond> actually returned. That would seem to indicate an error Raymond> in external-program not cmucl. Ok, I think it's probably caused by the defgeneric form that defines the method: (defgeneric start (program args &key input if-input-does-not-exist output if-output-exists error if-error-exists environment replace-environment-p status-hook) ... (:method (program args &rest rest) (declare (ignore program args rest)) (error "This CL implementation does not support START."))) Because this particular method ends with a call to error, it can never return, and thus has a return type of NIL. (A return type of NULL means it can return NIL. NIL means it doesn't return.) I think this is confusing cmucl. Not sure how to fix this in PCL. I also don't understand why the compilation of cmucl.lisp to add the actual method doesn't override this declaration. The hacky solution is to add #-cmucl for that method in the defgeneric. This makes things work. -- Ray
participants (2)
-
Mark Cox -
Raymond Toy