[Openmcl-devel] bug with usocket and/or trunk ccl - "error #22"

Chun Tian (binghe) binghe.lisp at gmail.com
Wed May 20 11:34:12 PDT 2015


CCL 1.11’s make-udp-socket function will call "%socket-connect” if keyword arguments remote-host and remote-port are provided with make-socket.  This is new in CCL 1.11:

(defun make-udp-socket (&rest keys
                        &key
                          (fd -1)
                          (connect :active)
                          (address-family :internet)
                          remote-host remote-port
                        &allow-other-keys)
  (unwind-protect
    (let (socket)
      (when (< fd 0)
        (setq fd (socket-call nil "socket"
                              (c_socket (ecase address-family
                                          (:internet #$PF_INET)
                                          (:internet6 #$PF_INET6))
                                        #$SOCK_DGRAM #$IPPROTO_UDP))))
      (setq socket (make-instance 'udp-socket
				  :device fd
				  :keys keys))
      (apply #'set-socket-options socket keys)
      (when (and (eql connect :active)
                 remote-host remote-port)
        (%socket-connect fd
                         (apply #'resolve-address
                                :host remote-host
                                :port remote-port
                                :allow-other-keys t
                                keys)
                         nil))
      (setq fd -1)
      socket)
    (unless (< fd 0)
      (fd-close fd))))

Il giorno 20/mag/2015, alle ore 20:00, Patrick Stein <clozure at nklein.com> ha scritto:

> usocket from the current quicklisp dist is calling (ccl::inet-connect ...) with a few parameters it gets by calling other unexported CCL functions.
> 
> Just this line is sufficient to get to the (first?) problem:
>> (usocket:socket-connect "localhost" 1111 :protocol ':datagram)
> 
> In a quick glance around trunk, I didn't see where make-udp-socket would invoke connect(2) or any way to do it after-the-fact.
> 
> -- Patrick <pat at nklein.com>
> 
> On May 20, 2015, at 12:49 PM, R. Matthew Emerson <rme at clozure.com> wrote:
> 
>> I can try to look at it.  What version of usocket are you using?  Is there a place I can get it easily so I can try to run your test case and duplicate the problem?
>> 
>> 
>>> On May 19, 2015, at 6:10 PM, Mark H. David <mhd at yv.org> wrote:
>>> 
>>> This works on an earlier CCL:
>>> Welcome to Clozure Common Lisp Version 1.10-r16196  (LinuxX8664)!
>>> 
>>> (let* ((host "localhost")
>>>      (port 1111)
>>>      (server-sock
>>>        (usocket:socket-connect nil nil :protocol ':datagram :local-host host :local-port port))
>>>      (client-sock
>>>        (usocket:socket-connect host port :protocol ':datagram))
>>>      (octet-vector
>>>        (make-array 2 :element-type '(unsigned-byte 8) :initial-contents `(,(char-code #\O) ,(char-code #\K))))
>>>      (recv-octet-vector
>>>        (make-array 2 :element-type '(unsigned-byte 8))))
>>> (usocket:socket-send client-sock octet-vector 2)
>>> (usocket:socket-receive server-sock recv-octet-vector 2)
>>> (prog1 (and (equalp octet-vector recv-octet-vector)
>>>             recv-octet-vector)
>>>   (usocket:socket-close server-sock)
>>>   (usocket:socket-close client-sock)))
>>> 
>>> =>
>>> 
>>> #(79 75)
>>> 
>>> 
>>> 
>>> On trunk CCL, updated/built on 5/19/15:
>>> Welcome to Clozure Common Lisp Version 1.11-dev-r16393M-trunk  (DarwinX8664)!
>>> 
>>> It gets an error:
>>> 
>>>> Debug: The condition Invalid argument (error #22) during attempt to connect to [unparsed, AF 2] occurred.
>>>> While executing: (:INTERNAL SWANK::INVOKE-DEFAULT-DEBUGGER), in process repl-thread(12).
>>>> Type :POP to abort, :R for a list of available restarts.
>>>> Type :? for other options.
>>> 1 > :b
>>> 
>>> (24034210) : 0 (FUNCALL #'#<(:INTERNAL SWANK::INVOKE-DEFAULT-DEBUGGER)>) 53
>>> (24034230) : 1 (FUNCALL #'#<SWANK/BACKEND:CALL-WITH-DEBUGGER-HOOK> NIL #<COMPILED-LEXICAL-CLOSURE (:INTERNAL SWANK::INVOKE-DEFAULT-DEBUGGER) #x302002623FFF>) 181
>>> (240342B8) : 2 (CALL-WITH-DEBUGGER-HOOK NIL #<COMPILED-LEXICAL-CLOSURE (:INTERNAL SWANK::INVOKE-DEFAULT-DEBUGGER) #x302002623FFF>) 181
>>> (240342E8) : 3 (INVOKE-DEFAULT-DEBUGGER #<USOCKET:UNKNOWN-ERROR #x30200250C31D>) 189
>>> (24034308) : 4 (SWANK-DEBUGGER-HOOK #<USOCKET:UNKNOWN-ERROR #x30200250C31D> #<Compiled-function SWANK:SWANK-DEBUGGER-HOOK #x3020008ADAEF>) 565
>>> (24034338) : 5 (BREAK-LOOP-HANDLE-ERROR #<USOCKET:UNKNOWN-ERROR #x30200250C31D> 75524225) 637
>>> (240343E0) : 6 (%ERROR #<USOCKET:UNKNOWN-ERROR #x30200250C31D> (:SOCKET NIL :REAL-ERROR #<SOCKET-CREATION-ERROR #x30200250D79D>) 75524225) 333
>>> (24034408) : 7 (RAISE-ERROR-FROM-ID :UNKNOWN NIL #<SOCKET-CREATION-ERROR #x30200250D79D>) 213
>>> (24034438) : 8 (HANDLE-CONDITION #<SOCKET-CREATION-ERROR #x30200250D79D> NIL) 709
>>> (24034470) : 9 (FUNCALL #'#<(:INTERNAL USOCKET:SOCKET-CONNECT)> #<SOCKET-CREATION-ERROR #x30200250D79D>) 61
>>> (24034490) : 10 (SIGNAL #<SOCKET-CREATION-ERROR #x30200250D79D>) 981
>>> (240344E8) : 11 (%ERROR #<SOCKET-CREATION-ERROR #x30200250D79D> NIL 75524258) 117
>>> (24034510) : 12 (SOCKET-ERROR NIL "connect" 22 NIL :CONNECT-ADDRESS #<SOCKET-ADDRESS [unparsed, AF 2]>) 1053
>>> (24034580) : 13 (INET-CONNECT 20 16777343 22276 NIL) 637
>>> (240345C8) : 14 (SOCKET-CONNECT "localhost" 1111 :PROTOCOL :DATAGRAM :ELEMENT-TYPE NIL :TIMEOUT NIL :DEADLINE NIL :NODELAY NIL :LOCAL-HOST NIL :LOCAL-PORT NIL) 1149
>>> (24034690) : 15 (FUNCALL #'#<Anonymous Function #x30200250E67F>) 149
>>> (240346A8) : 16 (CHEAP-EVAL (LET* (# # # # # ...) (USOCKET:SOCKET-SEND CLIENT-SOCK OCTET-VECTOR 2) (USOCKET:SOCKET-RECEIVE SERVER-SOCK RECV-OCTET-VECTOR 2) (PROG1 # # #))) 101
>>> 
>>> 
>>> 
>>> What's up with that?
>>> 
>>> Thanks,
>>> 
>>> Mark
>>> 
>>> 
>> 
>> 
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> https://lists.clozure.com/mailman/listinfo/openmcl-devel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 203 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20150520/8804d894/attachment.bin>


More information about the Openmcl-devel mailing list