On Sat, Mar 7, 2009 at 7:01 PM, Charlie Savage <cfis / savagexi.com> wrote:
> Mixing runtime libraries
> ========================
> The most obvious criticism of this plan is that it will lead to mixing of
> microsoft runtime c libraries.  From my experience this works as long as
> extension developers follow the rules described here:
>
> http://msdn.microsoft.com/en-us/library/ms235460(VS.80).aspx
>
> To be more concrete, this boils down to two simple rules:
>
> * If you call ALLOC or ALLOC_N, use xfree and not free
> * Don't call sprintf or printf in an extension, instead use
> rb_f_sprintf/rb_vsprintf/rb_io_printf
>
> If an extension violate these two rules then its obvious, a segmentation
> fault happens.  Thus these bugs are easy to find and easy to fix.
>
> Since VC6 is thankfully no longer available, supporting msvc absolutely,
> positively requires mixing c runtime libraries and therefore extension
> writers must follow these two simple rules.  We don't view this as a
> particularly difficult burden, especially in light of the changes extension
> developers already frequently have to make for 1.9.1 compatibility.

This works until you start linking third-party upstream source that
breaks these rules. If I were to make RbFoo that wraps libfoo, and
libfoo allocates memory through a method call, but doesn't provide an
explicit "free" mechanism, you're asking for trouble, and unless you
patch the upstream library, you won't have a fix.

-austin
-- 
Austin Ziegler * halostatue / gmail.com * http://www.halostatue.ca/
               * austin / halostatue.ca * http://www.halostatue.ca/feed/
               * austin / zieglers.ca