diff options
author | Florian Weimer <fweimer@redhat.com> | 2017-08-30 19:29:38 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2017-08-30 20:08:34 +0200 |
commit | ac3ed168d0c0b2b702319ac0db72c9b475a8c72e (patch) | |
tree | 31135c056fc400d97b639238df4748085c9b1614 /malloc/hooks.c | |
parent | 44bcba80f309b7517f8f954b0389e60eb421373b (diff) | |
download | glibc-ac3ed168d0c0b2b702319ac0db72c9b475a8c72e.tar glibc-ac3ed168d0c0b2b702319ac0db72c9b475a8c72e.tar.gz glibc-ac3ed168d0c0b2b702319ac0db72c9b475a8c72e.tar.bz2 glibc-ac3ed168d0c0b2b702319ac0db72c9b475a8c72e.zip |
malloc: Remove check_action variable [BZ #21754]
Clean up calls to malloc_printerr and trim its argument list.
This also removes a few bits of work done before calling
malloc_printerr (such as unlocking operations).
The tunable/environment variable still enables the lightweight
additional malloc checking, but mallopt (M_CHECK_ACTION)
no longer has any effect.
Diffstat (limited to 'malloc/hooks.c')
-rw-r--r-- | malloc/hooks.c | 55 |
1 files changed, 5 insertions, 50 deletions
diff --git a/malloc/hooks.c b/malloc/hooks.c index 1d80be20d2..dcd311e7c7 100644 --- a/malloc/hooks.c +++ b/malloc/hooks.c @@ -121,12 +121,7 @@ malloc_check_get_size (mchunkptr p) size -= c) { if (c <= 0 || size < (c + 2 * SIZE_SZ)) - { - malloc_printerr (check_action, "malloc_check_get_size: memory corruption", - chunk2mem (p), - chunk_is_mmapped (p) ? NULL : arena_for_chunk (p)); - return 0; - } + malloc_printerr ("malloc_check_get_size: memory corruption"); } /* chunk2mem size. */ @@ -232,17 +227,12 @@ mem2chunk_check (void *mem, unsigned char **magic_p) return p; } -/* Check for corruption of the top chunk, and try to recover if - necessary. */ - +/* Check for corruption of the top chunk. */ static int internal_function top_check (void) { mchunkptr t = top (&main_arena); - char *brk, *new_brk; - INTERNAL_SIZE_T front_misalign, sbrk_size; - unsigned long pagesz = GLRO (dl_pagesize); if (t == initial_top (&main_arena) || (!chunk_is_mmapped (t) && @@ -252,32 +242,7 @@ top_check (void) (char *) t + chunksize (t) == mp_.sbrk_base + main_arena.system_mem))) return 0; - malloc_printerr (check_action, "malloc: top chunk is corrupt", t, - &main_arena); - - /* Try to set up a new top chunk. */ - brk = MORECORE (0); - front_misalign = (unsigned long) chunk2mem (brk) & MALLOC_ALIGN_MASK; - if (front_misalign > 0) - front_misalign = MALLOC_ALIGNMENT - front_misalign; - sbrk_size = front_misalign + mp_.top_pad + MINSIZE; - sbrk_size += pagesz - ((unsigned long) (brk + sbrk_size) & (pagesz - 1)); - new_brk = (char *) (MORECORE (sbrk_size)); - if (new_brk == (char *) (MORECORE_FAILURE)) - { - __set_errno (ENOMEM); - return -1; - } - /* Call the `morecore' hook if necessary. */ - void (*hook) (void) = atomic_forced_read (__after_morecore_hook); - if (hook) - (*hook)(); - main_arena.system_mem = (new_brk - mp_.sbrk_base) + sbrk_size; - - top (&main_arena) = (mchunkptr) (brk + front_misalign); - set_head (top (&main_arena), (sbrk_size - front_misalign) | PREV_INUSE); - - return 0; + malloc_printerr ("malloc: top chunk is corrupt"); } static void * @@ -308,13 +273,7 @@ free_check (void *mem, const void *caller) __libc_lock_lock (main_arena.mutex); p = mem2chunk_check (mem, NULL); if (!p) - { - __libc_lock_unlock (main_arena.mutex); - - malloc_printerr (check_action, "free(): invalid pointer", mem, - &main_arena); - return; - } + malloc_printerr ("free(): invalid pointer"); if (chunk_is_mmapped (p)) { __libc_lock_unlock (main_arena.mutex); @@ -349,11 +308,7 @@ realloc_check (void *oldmem, size_t bytes, const void *caller) const mchunkptr oldp = mem2chunk_check (oldmem, &magic_p); __libc_lock_unlock (main_arena.mutex); if (!oldp) - { - malloc_printerr (check_action, "realloc(): invalid pointer", oldmem, - &main_arena); - return malloc_check (bytes, NULL); - } + malloc_printerr ("realloc(): invalid pointer"); const INTERNAL_SIZE_T oldsize = chunksize (oldp); checked_request2size (bytes + 1, nb); |