Date: Wed, 1 Dec 2004 13:43:06 -0500 (EST) From: Michael Furr To: Subject: Re: Some FFI bugs in lablgtk In-Reply-To: <20041201.104733.35026354.andrieu at ijm.jussieu.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 1 Dec 2004, Olivier Andrieu wrote: > It definitely can have ill effects. For instance, IIRC, this can crash > the toplevel pretty quickly as it will try to inspect the value and > print it. I see how this would definately be a problem for functions which return void instead of unit, but I don't see how it could crash the top level if a parameter is just ignored on the C side(although, I must admit I'm not very familiar with how the top-level does its value printing magic). Since OCaml will actually place the value on the stack, if the toplevel looks in the stack, it should find the correct value. > I had the opinion that the most common bug is accessing a value not > registered in the GC after an allocation, but this seems not to be the > case for lablgtk since you detected none. I would guess that it might have to do with the fact that most of the glue functions don't interact very much. So its usually the case that you need only look at a single function scope to see that a allocation function is called and all affected variables are protected. However, checking variable types requires one to flip back and forth between the ocaml and C code to double check things. Also humans seem to be notoriously bad at transposition errors, so the Val_int/Int_val errors are almost expected. Cheers, -Mike