(defun get-cols-example () (let* ((matrix (create-mat 5 7 +8uc1+)) (submat (foreign-alloc `(:struct cv-mat) :initial-contents '()))) (get-cols matrix submat 0 3) (foreign-free submat)))
when i run the above code with the (get-cols matrix submat 0 3) line commented or without foreign-free it runs fine but as it is above i get below error
Error in `/usr/bin/sbcl': free(): invalid next size (fast): 0x00007fffd4000c60 ***
in inferior lisp followed by many lines of code las below. All the fuinctions in the defun above are neccessary to reproduce issue:
======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x80996)[0x7ffff7154996] [0x100681f7b8] ======= Memory map: ======== 00400000-00435000 r-xp 00000000 08:03 135423 /usr/bin/sbcl 00635000-00636000 r-xp 00035000 08:03 135423 /usr/bin/sbcl 00636000-00648000 rwxp 00036000 08:03 135423 /usr/bin/sbcl
I dont have any foreign-free functions in my wrappers and the functions involved GET-COLS and CREATE-MAT are wrappers for OpenCV's cvGetCols and cvCreateMat...the wrappers are below for debugging purpose
;; CvMat* cvGetCols(const CvArr* arr, CvMat* submat, int start_col, int end_col) (defcfun ("cvGetCols" get-cols) (:pointer (:struct cv-mat)) "Returns array column span." (arr cv-arr) (submat (:pointer (:struct cv-mat))) (start-col :int) (end-col :int))
;; CvMat* cvCreateMat(int rows, int cols, int type) (defcfun ("cvCreateMat" create-mat) (:pointer (:struct cv-mat)) (rows :int) (cols :int) (type :int))
any way i can help debug this i will and any guidance on this issue is much appreciated =)
On 11.11.2013 19:28, Joeish W wrote:
;; CvMat* cvGetCols(const CvArr* arr, CvMat* submat, int start_col, int end_col) (defcfun ("cvGetCols" get-cols) (:pointer (:struct cv-mat)) "Returns array column span." (arr cv-arr) (submat (:pointer (:struct cv-mat))) (start-col :int) (end-col :int))
What is the definition of cv-arr? Is this really correct, or should it be (:pointer cv-arr) as is indicated by the C type in the comment.
Regs, Stephan
thanks for getting back to me so soon =) ....The definition of cv-arr is
;; CvArr (defctype cv-arr :pointer)
never thought of defining that as (:pointer cv-arr) ,would that be a good thing to do? i tested it defined as (:pointer cv-arr) and it does work, but as it is defined now (just as cv-arr) it works on over 100 functions....any other aid to tracking down this possible bug i can give let me know.....im dedicated fully to helping cfffi be the best it can be=)
On Monday, November 11, 2013 12:40 PM, Stephan Frank defclass@googlemail.com wrote:
On 11.11.2013 19:28, Joeish W wrote:
;; CvMat* cvGetCols(const CvArr* arr, CvMat* submat, int start_col, int end_col) (defcfun ("cvGetCols" get-cols) (:pointer (:struct cv-mat)) "Returns array column span." (arr cv-arr) (submat (:pointer (:struct cv-mat))) (start-col :int) (end-col :int))
What is the definition of cv-arr? Is this really correct, or should it be (:pointer cv-arr) as is indicated by the C type in the comment.
Regs, Stephan
On Mon, 11 Nov 2013 13:11:05 -0800 (PST), Joeish W said:
thanks for getting back to me so soon =) ....The definition of cv-arr is
;; CvArr (defctype cv-arr :pointer)
never thought of defining that as (:pointer cv-arr) ,would that be a good thing to do? i tested it defined as (:pointer cv-arr) and it does work, but as it is defined now (just as cv-arr) it works on over 100 functions....any other aid to tracking down this possible bug i can give let me know.....im dedicated fully to helping cfffi be the best it can be=)
It won't make any difference to this bug, but I think it would be clearer if you define cv-arr as :void and then use (:pointer cv-arr) everywhere else, so that it matches the C code.
__Martin