Register _cleanup function with atexit

* Register cleanup function with atexit
   instead of calling it explicitly on
   exit()
 * abort() no longer calls _cleanup:
   Flushing stdio buffers on abort is no
   longer required by POSIX.
 * dlmalloc no longer need to reset cleanup
   (see above)
 * Upstream findfp.c makebuf.c setvbuf.cexit.c
   to openbsd versions.

Bug: 14415367
Change-Id: I277058852485a9d3dbb13e5c232db5f9948d78ac
This commit is contained in:
Dmitriy Ivanov
2014-05-14 23:11:05 -07:00
parent 089c7c9217
commit 623b0d05bd
8 changed files with 73 additions and 100 deletions

View File

@@ -34,10 +34,7 @@ static void* named_anonymous_mmap(size_t length);
// Ugly inclusion of C file so that bionic specific #defines configure dlmalloc.
#include "../upstream-dlmalloc/malloc.c"
extern void (*__cleanup)();
static void __bionic_heap_corruption_error(const char* function) {
__cleanup = NULL; // The heap is corrupt. We can forget trying to shut down stdio.
__libc_fatal("heap corruption detected by %s", function);
}