orivej / pzmq

ZeroMQ 4.0+ Common Lisp bindings.

Home Page:http://orivej.github.io/pzmq/doc/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The value PZMQ::FREE-FN is not of type SB-SYS:SYSTEM-AREA-POINTER

phoe opened this issue · comments

(defcallback free-fn :void ((data :pointer) (hint :pointer))
  (declare (ignorable hint))
  (foreign-string-free data))

(defun msg-init-data (msg data)
  "Initialise ØMQ message from a supplied buffer.
@see{MSG-CLOSE}
@see{MSG-INIT-SIZE}
@see{MSG-INIT-DATA}"
  (let ((ptr (foreign-string-alloc data)))
    (with-c-error-check (:int)
      (%msg-init-data msg ptr (length data) 'free-fn nil))))

In this code, %msg-init-data refers to a callback named free-fn. The symbol does not get translated into the callback pointer though, which causes the following error:

The value
  PZMQ::FREE-FN
is not of type
  SB-SYS:SYSTEM-AREA-POINTER
when binding SB-ALIEN::VALUE
   [Condition of type TYPE-ERROR]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {1001F11B63}>)

Backtrace:
  0: (PZMQ::%MSG-INIT-DATA #.(SB-SYS:INT-SAP #X7FB249097F78) #.(SB-SYS:INT-SAP #X7FB240003580) 6 PZMQ::FREE-FN NIL)
  1: (PZMQ:MSG-INIT-DATA #.(SB-SYS:INT-SAP #X7FB249097F78) "World!")
  2: (HWSERVER "tcp://*:5555")
  3: (SB-INT:SIMPLE-EVAL-IN-LEXENV (HWSERVER) #<NULL-LEXENV>)
  4: (EVAL (HWSERVER))

Possible fix: replace 'free-fn with (cffi:callback free-fn), and the null hint argument with (cffi:null-pointer).