[plt-scheme] sqlite.plt seg faults with 370

From: Keith Frost (keith.l.frost at gmail.com)
Date: Fri Aug 31 19:22:59 EDT 2007

Hmmm... this is getting even more interesting.  I gave sqlid.plt a try, and
generated the transcript below:

Welcome to MzScheme v370 [3m], Copyright (c) 2004-2007 PLT Scheme Inc.
>   (require (planet "sqli.scm" ("oesterholt" "sqlid.plt" 1 5))
             (planet "sqld-sqlite.scm" ("oesterholt" "sqld-sqlite.plt" 1
>   (define *dbd* (sqld-sqlite-new "/home/keithf/test.s3"))
>   (define *dbh* (sqli-connect *dbd*))
>   (define dbi (sqli-closure *dbh*))
>   (require (lib "list.ss") (lib "etc.ss"))
>   (dbi 'query "select * from notes where id > 600000 and id < 601000;")
>   (define x (dbi 'fetchall))
>   (equal? (map (lambda (v) (string->number (car v))) x)
            (build-list 999 (lambda (i) (+ i 600001))))
> ; So far, so good... Now watch:

   (dbi 'query "select * from notes where id > 600000 and id < 1000000;")
procedure application: expected procedure, given: #<bad-value>; arguments
were: 2 ("603504" "5dd1d22a77beecafba55698c85e243b7")

 === context ===
/1/7/sqld-i-sqlite.scm:101:8: sqlite-i-callback
/1/7/sqld-i-sqlite.scm:64:42: ffi-wrapper:sqlite3_exec
/1/7/sqld-i-sqlite.scm:136:8: c-sqlite-query

If you manage to track down this problem, it's probably a similar difficulty
as I'm having with sqlite.plt

On 8/31/07, Hans Oesterholt-Dijkema <hdnews at gawab.com> wrote:
>  I experienced also seg faults with 370. However, I only noticed
> them while using threads. I think I've solved them in the sqlite driver.
> Maybe that helps? Have a go with sqld-sqlite.plt.
> --Hans
> Keith Frost schreef:
> Well, I'm at a loss, for now.  I've gone through sqlite.ss and added 'raw
> to every malloc call in the file, and I still get random memory corruption
> and segmentation violations when running, for example
> (select  *my-db*  "select * from  my_table where my_index > 600000 and
> my_index < 1000000")
> where there are 399999 result rows, with two columns, from my_table.
> I thought it might be related to callbacks, but there are no callbacks
> used in the particular code path I'm testing.  It seems to me that something
> must be going awry when libsqlite3 allocates the space to hold the strings
> from the query, and sets the pointers allocated by mzscheme to point to this
> space.  Is it possible that the system malloc() is getting shadowed somehow
> by mzscheme?  I know that sounds crazy....
> By the way, this behavior is not restricted to RHEL3; I see the same
> problems on Debian Etch.
> Is anybody else here getting substantial, reliable use out of sqlite.plton 370 or 371?  On what platform?
> Thanks,
> Keith Frost
> ------------------------------
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20070831/46bd0358/attachment.html>

Posted on the users mailing list.