1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

Restore locking in free_check.

This code is only used when MALLOC_CHECK_ is used.  Then some bogus
crashes and/or assert could result from the locking changes.  The code
ain't fast.
This commit is contained in:
Ulrich Drepper
2009-11-01 07:27:00 -08:00
parent 7f9cd6ed20
commit cc49a5a883
2 changed files with 25 additions and 17 deletions

View File

@ -1,3 +1,8 @@
2009-11-01 Ulrich Drepper <drepper@redhat.com>
* malloc/hooks.c (free_check): Restore locking and call _int_free
appropriately.
2009-10-30 Ulrich Drepper <drepper@redhat.com> 2009-10-30 Ulrich Drepper <drepper@redhat.com>
* version.h (VERSION): Bump for 2.11 release. * version.h (VERSION): Bump for 2.11 release.

View File

@ -276,13 +276,17 @@ free_check(mem, caller) Void_t* mem; const Void_t *caller;
mchunkptr p; mchunkptr p;
if(!mem) return; if(!mem) return;
(void)mutex_lock(&main_arena.mutex);
p = mem2chunk_check(mem, NULL); p = mem2chunk_check(mem, NULL);
if(!p) { if(!p) {
(void)mutex_unlock(&main_arena.mutex);
malloc_printerr(check_action, "free(): invalid pointer", mem); malloc_printerr(check_action, "free(): invalid pointer", mem);
return; return;
} }
#if HAVE_MMAP #if HAVE_MMAP
if (chunk_is_mmapped(p)) { if (chunk_is_mmapped(p)) {
(void)mutex_unlock(&main_arena.mutex);
munmap_chunk(p); munmap_chunk(p);
return; return;
} }
@ -291,12 +295,11 @@ free_check(mem, caller) Void_t* mem; const Void_t *caller;
memset(mem, 0, chunksize(p) - (SIZE_SZ+1)); memset(mem, 0, chunksize(p) - (SIZE_SZ+1));
#endif #endif
#ifdef ATOMIC_FASTBINS #ifdef ATOMIC_FASTBINS
_int_free(&main_arena, p, 0); _int_free(&main_arena, p, 1);
#else #else
(void)mutex_lock(&main_arena.mutex);
_int_free(&main_arena, p); _int_free(&main_arena, p);
(void)mutex_unlock(&main_arena.mutex);
#endif #endif
(void)mutex_unlock(&main_arena.mutex);
} }
static Void_t* static Void_t*