[racket-dev] Windows ffi's 'malloc raw' can't be paired with C 'free'

From: John Clements (clements at brinckerhoff.org)
Date: Tue Oct 18 18:27:28 EDT 2011

It looks like there's a problem with the ffi implementation of (malloc ... 'raw) in Windows.  In particular, if I call 'free()' in a C extension on a block of memory that was allocated with (malloc ... 'raw), I get the Windows equivalent of a core dump, with an exception code that indicates "heap corruption". I have a small piece of code that illustrates this, although one of the steps is compiling a windows DLL, which is somewhat nontrivial (though the source file is only a few lines).  Before I submit a bug report, is the Windows (malloc ... 'raw) already known not to cooperate with free()?  The obvious workaround is... just not to free the memory, but this is going to be an unsatisfying solution when dealing with 30Meg sound files.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4624 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20111018/261559b0/attachment.p7s>

Posted on the dev mailing list.