i'm trying to get cl-gd up and running on openmcl 1.0-rc1 (darwin32) using cffi-uffi-compat (cffi-luis branch).
some of the cl-gd tests crash my lisp, i think i've boiled it down to this (hopefully valid) test case which does work in uffi:
(def-struct a (x :int) (y :int))
(let ((array (allocate-foreign-object 'a 3))) (loop for i below 3 do (setf (get-slot-value (deref-array array '(:array a) i) 'a 'x) 1)) (get-slot-value (deref-array array '(:array a) 2) 'a 'x))
the (setf ...) SIGSEGVs in %mem-set.
i see similar results with sbcl 0.9.5.2.
thanks,
...bryan
bryan d.o'connor bryan-lisp@lunch.org writes:
i'm trying to get cl-gd up and running on openmcl 1.0-rc1 (darwin32) using cffi-uffi-compat (cffi-luis branch).
some of the cl-gd tests crash my lisp, i think i've boiled it down to this (hopefully valid) test case which does work in uffi:
(def-struct a (x :int) (y :int))
(let ((array (allocate-foreign-object 'a 3))) (loop for i below 3 do (setf (get-slot-value (deref-array array '(:array a) i) a 'x) 1)) (get-slot-value (deref-array array '(:array a) 2) 'a 'x))
the (setf ...) SIGSEGVs in %mem-set.
i see similar results with sbcl 0.9.5.2.
Thanks for bug report and test case! This should be fixed now. Let me know if something is still broken though. Changelog follows.
Sun Oct 2 13:24:16 WEST 2005 Luis Oliveira loliveira@common-lisp.net * pointer-eq and bug fixes
- New CFFI-SYS primitive: POINTER-EQ. Implemented for all Lisps except ECL and GCL. Exported it from the CFFI package. - Added POINTER-EQ to the user manual. - Bug fix: dereferencing an aggregate type should return a pointer to it, not dereference it as a :pointer. - Bug fix: mem-aref setf expander was returning a bogus getter (mem-ref instead of mem-aref). - Two regressions tests for the bugs above: DEREF.AGGREGATE and DEREF.ARRAY-OF-AGGREGATES.
Tue Sep 27 00:41:41 WEST 2005 Luis Oliveira loliveira@common-lisp.net * New test: void callback
Let me know if something is still broken though.
that fixed my problem, but now i have one more for you.
with structures containing arrays, get-slot-value with a slot after the array seems to reference into the array. i guess that it thinks that the array is actually a ptr to an array and the offset is miscalculated.
i attached some test code. again, this is on mac os x and happens with both openmcl and sbcl.
you should be able to run it with: (require :cffi-uffi-compat) (load "test") (test-package:run-test)
it should return (values 1 2 <array> 4 5), but instead (values 1 2 <array elt 0> <array elt 1> <array elt 2>)
thanks,
...bryan
"bryan d. o'connor" bryan-lisp@lunch.org writes:
Let me know if something is still broken though.
that fixed my problem, but now i have one more for you.
with structures containing arrays, get-slot-value with a slot after the array seems to reference into the array. i guess that it thinks that the array is actually a ptr to an array and the offset is miscalculated.
Yeah, the :array type was not much more than a typedef for a pointer.
This should be fixed now, but I didn't test other uses of the :array type much (I just fixed the bug in a lecture, the professor is starting to complain). Thanks for testing uffi-compat. Changelog follows.
Mon Oct 3 15:20:16 WEST 2005 Luis Oliveira loliveira@common-lisp.net * Fixed bug in uffi-compat, added new type.
- make the uffi-array-type be aggregate. (hopefully this didn't break uses of this type in other situations) - add uffi's :struct-pointer type. (not well tested, but passes all tests from uffi's regression suite)