From: SourceForge.net <no...@so...> - 2005-01-29 16:15:23
|
Bugs item #1112118, was opened at 2005-01-29 11:15 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101355&aid=1112118&group_id=1355 Category: ffi Group: segfault Status: Open Resolution: None Priority: 5 Submitted By: John Small (jwebsmall) Assigned to: Jörg Höhle (hoehle) Summary: handle_fault error2 sigsegv error resurfaced Initial Comment: I'm running CLisp 2.33.1 on win32 from binaries download from clisp.org. I've written a simple set of dbi/dbd packages for odbc and mysql. The odbc driver works fine. The mysql direct driver I ported to CLisp FFI from a c wrapper I wrote interfacing with the mysql client api. This c wrapper in c apps works fine also. The CLisp FFI mysql direct driver works okay on some simple data result sets. But on more complex result sets just calling mysql_fetch_row signals: handle_fault error2 sigsergv error with the customary address of the violation. Please note that the call to mysql_fetch_row simply returns a char ** which is an array of char * pointers to the field/column data strings. CLisp crashes in this call. Since I'm new to CL and this is my first CL program (although I have developed in Scheme) I figure I might be doing something wrong and that segment faults might actually be trigged by something I'm doing wrong. Essentially the code looks like this: #| from the mysql.h file MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result); Where MYSQL_ROW is defined as char ** and MYSQL_RES is a pointer to a mysql handle that I never introspect. The pseudo code below works fine on simple data sets only have simple values and a few columns. As soon as string data and returned NULL's are involved it crashes. But it will crash even when no NULL's are involved! |# (FFI:DEF-CALL-OUT mysql_fetch_row (:library "libmySQL.dll") (:language :stdc) (:name "mysql_fetch_row") (:arguments (res ffi:c-pointer)) (:return-type (ffi:c-array-ptr ffi:c-string))) ... ;; result is okay value from before and can ;; be used in functions to retrieve number of fields etc. (let ((row (mysql_fetch_row result)) ;; crashes here! (fields nil)) (if row (do ((i 0 (1+ i))) ((>= i num-fields) (setf fields (nreverse fields))) (push (aref row i) fields))) ;; aref crashes on null values which is a separate problem Thanks for any help. If you need my complete package sources I can send those also. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101355&aid=1112118&group_id=1355 |