Changing malloc/debug stuff

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Changing malloc/debug stuff

Salz, Rich

I want to change the memory alloc/debug things.

 

Right now there are several undocumented functions to allow you to swap-out the malloc/realloc/free routines, wrappers that call those routines, debug versions of those wrappers, and functions to set the set-options versions of those functions.  Yes, really J  Is anyone using that stuff?

 

I want to change the model so that there are three wrappers around malloc/realloc/free, and that the only thing you can do is change that wrapper.  This is vastly simpler and easier to understand.  I also documented it.  A version can be found at https://github.com/openssl/openssl/pull/450

 

I’ve posted about this before.  But I’m asking again if this kind of change will cause problems for anyone.

 

Thanks.

 

-- 

Senior Architect, Akamai Technologies

IM: [hidden email] Twitter: RichSalz

 


_______________________________________________
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev
Reply | Threaded
Open this post in threaded view
|

Re: [openssl-users] Changing malloc/debug stuff

Viktor Dukhovni
On Thu, Dec 17, 2015 at 09:28:28AM +0000, Salz, Rich wrote:

> I want to change the model so that there are three wrappers around
> malloc/realloc/free, and that the only thing you can do is change that
> wrapper.  This is vastly simpler and easier to understand.  I also
> documented it.  A version can be found at
> https://github.com/openssl/openssl/pull/450
>
> I've posted about this before.  But I'm asking again if this kind of change will cause problems for anyone.

Does CRYPTO_mem_leaks(bio_err) continue to work after the change?
It is used in the test-suite and is fairly useful for that.

--
        Viktor.
_______________________________________________
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev
Reply | Threaded
Open this post in threaded view
|

Re: [openssl-users] Changing malloc/debug stuff

Salz, Rich
 
> Does CRYPTO_mem_leaks(bio_err) continue to work after the change?
> It is used in the test-suite and is fairly useful for that.

Yes it does!
_______________________________________________
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev
Reply | Threaded
Open this post in threaded view
|

Re: [openssl-users] Changing malloc/debug stuff

Nico Williams
In reply to this post by Salz, Rich
On Thu, Dec 17, 2015 at 09:28:28AM +0000, Salz, Rich wrote:
> I want to change the memory alloc/debug things.
>
> Right now there are several undocumented functions to allow you to
> swap-out the malloc/realloc/free routines, wrappers that call those
> routines, debug versions of those wrappers, and functions to set the
> set-options versions of those functions.  Yes, really :)  Is anyone
> using that stuff?

This is another one of those things that isn't easy to deal with sanely
the way OpenSSL is actually used (i.e., by other libraries as well as by
apps).

> I want to change the model so that there are three wrappers around
> malloc/realloc/free, and that the only thing you can do is change that
> wrapper.  This is vastly simpler and easier to understand.  I also
> documented it.  A version can be found at
> https://github.com/openssl/openssl/pull/450

This seems much more sane.

Nico
--
_______________________________________________
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev
Reply | Threaded
Open this post in threaded view
|

Re: [openssl-users] Changing malloc/debug stuff

Salz, Rich
> > https://github.com/openssl/openssl/pull/450
>
> This seems much more sane.

I'll settle for less insane :)

_______________________________________________
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev
Reply | Threaded
Open this post in threaded view
|

Re: [openssl-users] Changing malloc/debug stuff

Nico Williams
On Thu, Dec 17, 2015 at 08:16:50PM +0000, Salz, Rich wrote:
> > > https://github.com/openssl/openssl/pull/450
> >
> > This seems much more sane.
>
> I'll settle for less insane :)

That is, I think, the best you can do.  Some allocations might have
taken place by the time a wrapper or alternative allocator is
installed, in which case something bad will happen.  In the case of
alternative allocators the something bad is "it blows up", while in the
case of a wrapper the something bad is "some state/whatever will be
off".

A fully sane approach would be to have every allocated object internally
point to its destructor, and then always destroy by calling that
destructor instead of a global one.  (Or call a global one that knows
how to find the object's private destructor pointer, and then calls
that.)  If you wish, something more OO-ish.  But for many allocations
that's not possible because they aren't "objects" in the sense that
matters.  You could always wrap allocations so that they always have
room at the front for the corresponding destructor, then return the
offset of the end of that pointer, but this will be very heavy-duty for
many allocations.  So, all in all, I like and prefer your approach.

Nico
--
_______________________________________________
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev