diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-05-21 20:01:15 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2007-05-21 20:01:15 +0000 |
commit | 75831cc48d3fef9b0bb247aabbcdaceef85efa23 (patch) | |
tree | 49952b4916fa5d21f944970fa0ff5392742e9378 /malloc | |
parent | 473e6b3f8fcf9c937d5a85da70b95f5c13f4a28f (diff) | |
download | glibc-75831cc48d3fef9b0bb247aabbcdaceef85efa23.tar.gz glibc-75831cc48d3fef9b0bb247aabbcdaceef85efa23.tar.xz glibc-75831cc48d3fef9b0bb247aabbcdaceef85efa23.zip |
Backported selected fixes from 2007-05-{17,18,21}. cvs/fedora-glibc-2_6-2
Diffstat (limited to 'malloc')
-rw-r--r-- | malloc/Makefile | 1 | ||||
-rw-r--r-- | malloc/arena.c | 3 | ||||
-rw-r--r-- | malloc/hooks.c | 27 | ||||
-rw-r--r-- | malloc/malloc.c | 30 | ||||
-rw-r--r-- | malloc/mcheck.c | 8 |
5 files changed, 25 insertions, 44 deletions
diff --git a/malloc/Makefile b/malloc/Makefile index c251bcfb9d..c39eae5474 100644 --- a/malloc/Makefile +++ b/malloc/Makefile @@ -104,7 +104,6 @@ $(objpfx)memusagestat: $(memusagestat-modules:%=$(objpfx)%.o) include ../Rules CFLAGS-mcheck-init.c = $(PIC-ccflag) -CFLAGS-malloc.c += -DMALLOC_DEBUG $(objpfx)libmcheck.a: $(objpfx)mcheck-init.o -rm -f $@ diff --git a/malloc/arena.c b/malloc/arena.c index 9e3ff47347..ce64335567 100644 --- a/malloc/arena.c +++ b/malloc/arena.c @@ -370,9 +370,6 @@ ptmalloc_init_minimal (void) mp_.top_pad = DEFAULT_TOP_PAD; #endif mp_.n_mmaps_max = DEFAULT_MMAP_MAX; -#if MALLOC_DEBUG - mp_.n_mmaps_cmax = DEFAULT_MMAP_MAX; -#endif mp_.mmap_threshold = DEFAULT_MMAP_THRESHOLD; mp_.trim_threshold = DEFAULT_TRIM_THRESHOLD; mp_.pagesize = malloc_getpagesize; diff --git a/malloc/hooks.c b/malloc/hooks.c index cde3e18cbd..1e01b73afd 100644 --- a/malloc/hooks.c +++ b/malloc/hooks.c @@ -496,7 +496,7 @@ free_starter(mem, caller) Void_t* mem; const Void_t *caller; then the hooks are reset to 0. */ #define MALLOC_STATE_MAGIC 0x444c4541l -#define MALLOC_STATE_VERSION (0*0x100l + 2l) /* major*0x100 + minor */ +#define MALLOC_STATE_VERSION (0*0x100l + 3l) /* major*0x100 + minor */ struct malloc_save_state { long magic; @@ -507,9 +507,6 @@ struct malloc_save_state { unsigned long trim_threshold; unsigned long top_pad; unsigned int n_mmaps_max; -#if MALLOC_DEBUG - unsigned int n_mmaps_cmax; -#endif unsigned long mmap_threshold; int check_action; unsigned long max_sbrked_mem; @@ -553,9 +550,6 @@ public_gET_STATe(void) ms->trim_threshold = mp_.trim_threshold; ms->top_pad = mp_.top_pad; ms->n_mmaps_max = mp_.n_mmaps_max; -#if MALLOC_DEBUG - ms->n_mmaps_cmax = mp_.n_mmaps_cmax; -#endif ms->mmap_threshold = mp_.mmap_threshold; ms->check_action = check_action; ms->max_sbrked_mem = main_arena.max_system_mem; @@ -601,8 +595,9 @@ public_sET_STATe(Void_t* msptr) assert(ms->av[2*i+3] == 0); first(b) = last(b) = b; } else { - if(i<NSMALLBINS || (largebin_index(chunksize(ms->av[2*i+2]))==i && - largebin_index(chunksize(ms->av[2*i+3]))==i)) { + if(ms->version >= 3 && + (i<NSMALLBINS || (largebin_index(chunksize(ms->av[2*i+2]))==i && + largebin_index(chunksize(ms->av[2*i+3]))==i))) { first(b) = ms->av[2*i+2]; last(b) = ms->av[2*i+3]; /* Make sure the links to the bins within the heap are correct. */ @@ -622,14 +617,22 @@ public_sET_STATe(Void_t* msptr) } } } + if (ms->version < 3) { + /* Clear fd_nextsize and bk_nextsize fields. */ + b = unsorted_chunks(&main_arena)->fd; + while (b != unsorted_chunks(&main_arena)) { + if (!in_smallbin_range(chunksize(b))) { + b->fd_nextsize = NULL; + b->bk_nextsize = NULL; + } + b = b->fd; + } + } mp_.sbrk_base = ms->sbrk_base; main_arena.system_mem = ms->sbrked_mem_bytes; mp_.trim_threshold = ms->trim_threshold; mp_.top_pad = ms->top_pad; mp_.n_mmaps_max = ms->n_mmaps_max; -#if MALLOC_DEBUG - mp_.n_mmaps_cmax = ms->n_mmaps_cmax; -#endif mp_.mmap_threshold = ms->mmap_threshold; check_action = ms->check_action; main_arena.max_system_mem = ms->max_sbrked_mem; diff --git a/malloc/malloc.c b/malloc/malloc.c index e061db94d6..0755fd8f8d 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -2358,9 +2358,6 @@ struct malloc_par { /* Memory map support */ int n_mmaps; int n_mmaps_max; -#if MALLOC_DEBUG - int n_mmaps_cmax; -#endif int max_n_mmaps; /* the mmap_threshold is dynamic, until the user sets it manually, at which point we need to disable any @@ -2572,7 +2569,7 @@ static void do_check_chunk(av, p) mstate av; mchunkptr p; #if HAVE_MMAP /* address is outside main heap */ if (contiguous(av) && av->top != initial_top(av)) { - assert(((char*)p) < min_address || ((char*)p) > max_address); + assert(((char*)p) < min_address || ((char*)p) >= max_address); } /* chunk is page-aligned */ assert(((p->prev_size + sz) & (mp_.pagesize-1)) == 0); @@ -2876,8 +2873,6 @@ static void do_check_malloc_state(mstate av) assert(total <= (unsigned long)(mp_.max_total_mem)); assert(mp_.n_mmaps >= 0); #endif - assert(mp_.n_mmaps <= mp_.n_mmaps_cmax); - assert(mp_.n_mmaps_max <= mp_.n_mmaps_cmax); assert(mp_.n_mmaps <= mp_.max_n_mmaps); assert((unsigned long)(av->system_mem) <= @@ -3475,13 +3470,6 @@ munmap_chunk(p) mchunkptr p; } mp_.n_mmaps--; -#if MALLOC_DEBUG - if (mp_.n_mmaps_cmax > mp_.n_mmaps_max) - { - assert (mp_.n_mmaps_cmax == mp_.n_mmaps + 1); - mp_.n_mmaps_cmax = mp_.n_mmaps; - } -#endif mp_.mmapped_mem -= total_size; int ret __attribute__ ((unused)) = munmap((char *)block, total_size); @@ -5397,9 +5385,6 @@ mstate av; size_t n_elements; size_t* sizes; int opts; Void_t* chunks[]; mp_.n_mmaps_max = 0; mem = _int_malloc(av, size); mp_.n_mmaps_max = mmx; /* reset mmap */ -#if MALLOC_DEBUG - mp_.n_mmaps_cmax = mmx; -#endif if (mem == 0) return 0; @@ -5725,17 +5710,8 @@ int mALLOPt(param_number, value) int param_number; int value; res = 0; else #endif - { -#if MALLOC_DEBUG - if (mp_.n_mmaps <= value) - mp_.n_mmaps_cmax = value; - else - mp_.n_mmaps_cmax = mp_.n_mmaps; -#endif - - mp_.n_mmaps_max = value; - mp_.no_dyn_threshold = 1; - } + mp_.n_mmaps_max = value; + mp_.no_dyn_threshold = 1; break; case M_CHECK_ACTION: diff --git a/malloc/mcheck.c b/malloc/mcheck.c index 9f88843445..28210068ff 100644 --- a/malloc/mcheck.c +++ b/malloc/mcheck.c @@ -1,5 +1,5 @@ /* Standard debugging hooks for `malloc'. - Copyright (C) 1990-1997,99,2000,01,02 Free Software Foundation, Inc. + Copyright (C) 1990-1997,1999,2000-2002,2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Written May 1989 by Mike Haertel. @@ -280,6 +280,12 @@ memalignhook (__malloc_size_t alignment, __malloc_size_t size, static __ptr_t reallochook (__ptr_t ptr, __malloc_size_t size, const __ptr_t caller) { + if (size == 0) + { + freehook (ptr, caller); + return NULL; + } + struct hdr *hdr; __malloc_size_t osize; |