[plt-scheme] scheme/foreign issues - string conversion and DrScheme crashing

From: Ben Simon (benjisimon at gmail.com)
Date: Thu Dec 25 18:35:09 EST 2008

On Thu, Dec 25, 2008 at 6:29 PM, Ben Simon <benjisimon at gmail.com> wrote:

> On Thu, Dec 25, 2008 at 4:49 PM, Eli Barzilay <eli at barzilay.org> wrote:
>
>> On Dec 25, Ben Simon wrote:
>> > I wonder if I'm hosing things up because I'm calling mysql_init without
>> an
>> > argument. The API says that if the argument is null, it returns back a
>> fresh
>> > mysql handle.  That's what I was intending.  But, by not explicitly
>> handing
>> > in NULL, i may be corrupting matters.
>>
>> That sounds very likely: if you omit the type from the interface, then
>> the foreign function will just use whatever junk happens to be on the
>> stack.  And it sounds like mysql will just assume that it's a pointer
>> to a struct to fill -- so it stores that information in that random
>> place.  (And it shouldn't be surprising that this leads to a crash at
>> some later point.)
>>
>
Whoo! That appears to be it.  Since I've made that change, I've been crash
free.

Thanks Eli!

-Ben

-- 
Have an idea for software?  I can make it happen -
http://www.ideas2executables.com
My Blog: http://benjisimon.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20081225/68fbae94/attachment.html>

Posted on the users mailing list.