(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 =)