Bug in __register_exitproc() in __atexit.c

Corinna Vinschen vinschen@redhat.com
Wed Dec 9 09:31:00 GMT 2015

On Dec  8 16:40, Freddie Chopin wrote:
> Hello!
> Today I noticed that even when I disable dynamic allocation of memory in 
> atexit (with --disable-newlib-atexit-dynamic-alloc switch) malloc() is used in 
> __register_exitproc().
> First of all, if this switch is used, then _ATEXIT_DYNAMIC_ALLOC is not 
> defined, so the first use of malloc() in this function - at line 93 - is 
> indeed disabled. But if small reent is used, malloc() is used again at line 
> 120 - this time it's not conditional on _ATEXIT_DYNAMIC_ALLOC being defined.
> Moreover, at first glance it seems that there's a bug in this function. The 
> __atexit_lock lock is acquired at entry, but there are at two places where it 
> is not released before return - at line 86 and at line 91.
> Should I try to provide a patch for both issues?

That would be nice :)


Corinna Vinschen
Cygwin Maintainer
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20151209/adfcd6b0/attachment.sig>

More information about the Newlib mailing list