From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA21033; Wed, 30 Apr 2003 23:20:15 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id XAA20395 for ; Wed, 30 Apr 2003 23:20:14 +0200 (MET DST) Received: from opus.davidb.org (66-75-152-1.san.rr.com [66.75.152.1]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h3ULKCH04851 for ; Wed, 30 Apr 2003 23:20:13 +0200 (MET DST) Received: from davidb by opus.davidb.org with local (Exim 3.31 #1 (Debian)) id 19Ayzs-0006TN-00 for ; Wed, 30 Apr 2003 14:20:12 -0700 Date: Wed, 30 Apr 2003 14:20:12 -0700 From: David Brown To: Caml List Subject: Re: [Caml-list] Binding problem, fixed. Message-ID: <20030430212012.GA24849@opus.davidb.org> References: <20030430052829.GA19254@opus.davidb.org> <20030430060602.GA20670@opus.davidb.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030430060602.GA20670@opus.davidb.org> User-Agent: Mutt/1.4i X-Spam: no; 0.00; caml-list:01 segv:01 'var':99 alloc:01 allocations:01 ocaml:01 garbage:01 0700,:01 collector:02 binding:03 string:03 dave:03 wrote:03 variable:03 allocated:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, Apr 29, 2003 at 11:06:02PM -0700, David Brown wrote: > I'm trying to create a binding to sqlite. It seems to work most of the > time, except occasionally it makes the ocaml GC segv. I found a pair of problems. The first was using: I used Field (var, n) = ... where I needed to use Store_field. To, make sure I understand this. I am allowed to use Field (var, n) = as long as I can guarantee that 'var' is not shared. In other words, it was allocated with alloc_small (or equivalent), and no other allocations have taken place. If I'm doing other allocations (say to come up with the values to store), then I need to make sure that modify gets called. The second was to use Store_field (var, n, copy_string (...)); The string needs to be put in a variable and assigned in a separate step. Otherwise 'var' might get moved by the garbage collector, and C doesn't guarantee anything about evaluation order. I put the working versions of the binding files on the web server if anyone wants to look at them. They still need some cleaning up. Dave ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners