malloc & friends hidden proto issues

Khem Raj raj.khem at gmail.com
Fri Jul 17 07:54:45 UTC 2009


On (17/07/09 07:36), Carmelo AMOROSO wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Folks,
> I've recently added for testing hidden_proto in {m,re,c}alloc functions to
> ensure that from within the libc we always called the hidden __GI_xxx symbols.
> 
> Using this uClibc with firefox and bash I found a problem.
> Both bash and firefox provide a their own implementation of memory allocation
> functions (bash internally, firefox by libejmalloc.so).
> 
> Because the dynamic linker will search undefined symbols firstly in the application,
> any reference to malloc/free functions will be resolved by the application's symbols.
> 
> If we use the hidden_protos, calls to malloc/free from libc are resolved inside libc itslef
> at it is expected.
> 
> Now we have getcwd and strdup that use malloc for allocate memory and return the
> pointer to the caller. This memory is after freed by the application, calling free(),
> that is not the libc one implementation, leading to error, sigbus and so on.
> 
> Do you think it is wrong to use the hidden_protos for this class of functions,
> or we should think better at how internal symbols are actually used by uClibc ?

IMO when reimplementing malloc by applications, other functions referring to malloc in libc 
should also be reimplemented in terms of user defined malloc and free.

bash has --without-bash-malloc which could be there because of such errors.

Thx

-Khem


More information about the uClibc mailing list