Bug in __register_exitproc() in __atexit.c
Freddie Chopin
freddie_chopin@op.pl
Wed Dec 9 03:01:00 GMT 2015
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
More information about the Newlib
mailing list