This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Bug in __register_exitproc() in __atexit.c
- From: Freddie Chopin <freddie_chopin at op dot pl>
- To: newlib at sourceware dot org
- Date: Tue, 08 Dec 2015 16:40:23 +0100
- Subject: Bug in __register_exitproc() in __atexit.c
- Authentication-results: sourceware.org; auth=none
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?
Regards,
FCh