diff options
author | Ulrich Drepper <drepper@redhat.com> | 2008-01-09 20:35:03 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2008-01-09 20:35:03 +0000 |
commit | b34437015bac85001eeed5d6407f9241bbff3b8e (patch) | |
tree | 1f7614f53edd7c1483f7f38fcce6a1affbe9c6f9 | |
parent | 4b1b449d1d4fda5658a3eb8378413aa224de0cf6 (diff) | |
download | glibc-b34437015bac85001eeed5d6407f9241bbff3b8e.tar.gz glibc-b34437015bac85001eeed5d6407f9241bbff3b8e.tar.xz glibc-b34437015bac85001eeed5d6407f9241bbff3b8e.zip |
[BZ #5553]
2008-01-09 Ulrich Drepper <drepper@redhat.com> [BZ #5553] * malloc/malloc.c (public_mALLOc): Set ar_ptr when trying main_arena. (public_mEMALIGn): Likewise. Patch mostly by Daniel Jacobowitz.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | malloc/malloc.c | 19 |
2 files changed, 18 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog index d646af8472..4e493217e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-01-09 Ulrich Drepper <drepper@redhat.com> + + [BZ #5553] + * malloc/malloc.c (public_mALLOc): Set ar_ptr when trying main_arena. + (public_mEMALIGn): Likewise. + Patch mostly by Daniel Jacobowitz. + 2008-01-09 Jakub Jelinek <jakub@redhat.com> * sysdeps/unix/sysv/linux/i386/makecontext.S (__makecontext): Avoid diff --git a/malloc/malloc.c b/malloc/malloc.c index fc8a83c328..f0425bddf5 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -1,5 +1,5 @@ /* Malloc implementation for multiple threads without lock contention. - Copyright (C) 1996-2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1996-2006, 2007, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Wolfram Gloger <wg@malloc.de> and Doug Lea <dl@cs.oswego.edu>, 2001. @@ -3553,9 +3553,10 @@ public_mALLOc(size_t bytes) /* Maybe the failure is due to running out of mmapped areas. */ if(ar_ptr != &main_arena) { (void)mutex_unlock(&ar_ptr->mutex); - (void)mutex_lock(&main_arena.mutex); - victim = _int_malloc(&main_arena, bytes); - (void)mutex_unlock(&main_arena.mutex); + ar_ptr = &main_arena; + (void)mutex_lock(&ar_ptr->mutex); + victim = _int_malloc(ar_ptr, bytes); + (void)mutex_unlock(&ar_ptr->mutex); } else { #if USE_ARENAS /* ... or sbrk() has failed and there is still a chance to mmap() */ @@ -3760,17 +3761,19 @@ public_mEMALIGn(size_t alignment, size_t bytes) if(!ar_ptr) return 0; p = _int_memalign(ar_ptr, alignment, bytes); - (void)mutex_unlock(&ar_ptr->mutex); if(!p) { /* Maybe the failure is due to running out of mmapped areas. */ if(ar_ptr != &main_arena) { - (void)mutex_lock(&main_arena.mutex); - p = _int_memalign(&main_arena, alignment, bytes); - (void)mutex_unlock(&main_arena.mutex); + (void)mutex_unlock(&ar_ptr->mutex); + ar_ptr = &main_arena; + (void)mutex_lock(&ar_ptr->mutex); + p = _int_memalign(ar_ptr, alignment, bytes); + (void)mutex_unlock(&ar_ptr->mutex); } else { #if USE_ARENAS /* ... or sbrk() has failed and there is still a chance to mmap() */ ar_ptr = arena_get2(ar_ptr->next ? ar_ptr : 0, bytes); + (void)mutex_unlock(&ar_ptr->mutex); if(ar_ptr) { p = _int_memalign(ar_ptr, alignment, bytes); (void)mutex_unlock(&ar_ptr->mutex); |