Open svetlyak40wt opened 3 years ago
To reproduce this error we can use this minimal example:
(defun test-vector ()
(let ((vector (scriptl::to-octets (format nil "~8,'0X" 10))))
(fli:with-dynamic-lisp-array-pointer (ptr-var vector)
ptr-var)))
As a quickfix, I've wrapped the TO-OCTETS
body with system:in-static-area
macro (which is deprecated in LW, but still works):
(eval-when (:compile-toplevel :load-toplevel :execute)
(defun to-octets (value)
(system:in-static-area
(etypecase value
(string (string-to-utf-8-bytes value))
((unsigned-byte 8) (make-array 1 :element-type '(unsigned-byte 8)
:initial-element value))
(octet-vector value)
(t (string-to-utf-8-bytes (princ-to-string value)))))))
If you wish, I'll make a patch which will run to-octets
under the in-static-area
macro?
Or may be it is better to convert it's result into a static vectro separately because in-static-area
is deprecated?
Submitting a PR for LispWorks with whatever the best strategy is will be the most expedient thing... I'm not really set up for CL development at the moment and was never too familiar with the LW implementation.
At a glance I'm not sure why static vectors are being used at all here; I don't see them explicitly mentioned in either ScriptL or trivial-utf8, and it would seem excessive to require such. But it's early and I've only had a few sips of coffee. Perhaps this isn't the static-vectors
sense.
At a glance I'm not sure why static vectors are being used at all here; I don't see them explicitly mentioned in either ScriptL or trivial-utf8, and it would seem excessive to require such. But it's early and I've only had a few sips of coffee. Perhaps this isn't the static-vectors sense.
Under the hood, when you are using write-sequence
on the socket, returned by iolib
's accept
, it uses cffi
macro with-pointer-to-vector-data
before call to memcpy
:
(with-pointer-to-vector-data (src-ptr src)
(isys:memcpy
(inc-pointer dst-ptr doff)
(inc-pointer src-ptr soff)
length))
And here is this macro definition for LispWorks:
(defmacro with-pointer-to-vector-data ((ptr-var vector) &body body)
"Bind PTR-VAR to a pointer at the data in VECTOR."
`(fli:with-dynamic-lisp-array-pointer (,ptr-var ,vector)
,@body))
But documentation on with-dynamic-lisp-array-pointer says the vector have to be static.
That is why when you are using write-sequence
to write to iolib
's socket, under the LispWorks you need to provide a statically allocated vector.
I'll create a pull request soon.
Created a pull: https://github.com/rpav/ScriptL/pull/11 it works for me.
When running server under LispWorks 7.1.2 I get this error during command execution (I'm trying example from the README):