[RFC 1/2] Adding custom destructor for free.

Ondřej Bílka neleai@seznam.cz
Tue Nov 19 11:45:00 GMT 2013


On Tue, Nov 19, 2013 at 11:29:27AM +0100, Florian Weimer wrote:
> On 11/11/2013 03:20 PM, Ondřej Bílka wrote:
> 
> >I wonder if this would be a core functionality or by adding new
> >library?
> 
> There are already libraries for doing this.  Adding it to libc would
> only help if the existing (incompatible) libraries would standardize
> on the libc interfaces, which seems unlikely.
>
Could you provide links? Do they require to use other function than free
which makes them less flexible?
 
I want to know what features they offer and what could be standardized.

A custom free here is more a prerequisite for other features.

> I also think it's hardly radical enough, given that it negatively
> interacts with malloc hooking.
> 
Not necceassarily. I could make these features working on arbitrary
allocator with small slowdown. A custom allocator could get these
features by -lmalloc_intercept which would handle these for him.
Alternatively when allocator is LD_PRELOADED then use
LD_PRELOAD=libmalloc_intercept.so:allocator.so

Doing this would help as already you cannot expect malloc_hook work
with custom allocator. 

Then there is a hack, that we could make linker prepend LD_PRELOAD with
intercept library which would work always but is ugly.



More information about the Libc-alpha mailing list