Hi, Joonas;

Yesterday, David said simple solution of yours. I think I found the case
of segfault.

########## cut here ##########
--- sqlite3.scm.old 2012-01-24 00:22:10.000000000 +0900
+++ sqlite3.scm 2012-04-29 10:37:37.999722092 +0900
@@ -284,11 +284,11 @@
   (let ((bind-blob (pointer->procedure
                     int
                     (dynamic-func "sqlite3_bind_blob" libsqlite3)
-                    (list '* int '* int '*)))
+                    (list '* int '* int int)))
         (bind-text (pointer->procedure
                     int
                     (dynamic-func "sqlite3_bind_text" libsqlite3)
-                    (list '* int '* int '*)))
+                    (list '* int '* int int)))
         (bind-int64 (pointer->procedure
                      int
                      (dynamic-func "sqlite3_bind_int64" libsqlite3)
@@ -301,8 +301,7 @@
                     int
                     (dynamic-func "sqlite3_bind_null" libsqlite3)
                     (list '* int)))
-        (sqlite-transient (bytevector->pointer
-                           (make-bytevector (sizeof '*) #xff))))
+        (sqlite-transient -1))
     (lambda (stmt key val)
       (assert-live-stmt! stmt)
       (let ((idx (key->index stmt key))
########## cut here ##########

2012/4/27 Sunjoong Lee <[email protected]>
>
> Same crash on Guile 2.0.5. It looks like string encoding problem. Suppose
> name be an integer not a string like 10, it would not crash. sqlite-bind
> of Guile-SQLite3 will deliver this 10 to sqlite3_bind_int64 of libsqlite3.
> If a string, it will use sqlite3_bind_text of libsqlite3. Before
> delivering, it will encoding this string to utf-8 string pointer because
> sqlite3_bind_text need to know string pointer and it's length. I think you
> or Andy may look around that.
>

 In the http://www.sqlite.org/c3ref/c_static.html ,
#define SQLITE_TRANSIENT   ((sqlite3_destructor_type)-1)

I.e, SQLITE_TRANSIENT is actually -1, not some position of
memory. sqlite-bind of Guile-SQLite3 had treated it as a pointer, an
address of memory position.

Oh, another one; your test code ex0.scm has a bug.

--- ex0.scm.old 2012-04-29 10:57:09.717398060 +0900
+++ ex0.scm 2012-04-29 10:39:20.051261614 +0900
@@ -34,7 +34,7 @@
   ;; This finalize call in particular seems to break things
   (sqlite-finalize stmt)
   ;; This seems to be never reached.
-  (display "finalized\n")))
+  (display "finalized\n"))

 (display "closing\n")
 (sqlite-close db)
\ No newline at end of file

Reply via email to