diff --git a/src/apply_low.h b/src/apply_low.h index 9d4567413799bd72c2e7dd088c4375f22315ee4f..b7757f9c26789f28009c5ec4197ac37b642011e4 100644 --- a/src/apply_low.h +++ b/src/apply_low.h @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: apply_low.h,v 1.16 2003/03/14 15:50:43 grubba Exp $ +|| $Id: apply_low.h,v 1.17 2003/03/15 16:18:32 grubba Exp $ */ { @@ -228,10 +228,11 @@ Pike_sp++; MEMMOVE(Pike_sp-args,Pike_sp-args-1,sizeof(struct svalue)*args); #ifdef DEBUG_MALLOC - { + if (args) { int i; /* Note: touch the dead svalue too. */ for (i=args+2; i > 0; i--) { + fprintf(stderr, "Checking i:%d\n", i); dmalloc_touch_svalue(Pike_sp-i); } } diff --git a/src/block_alloc.h b/src/block_alloc.h index 53d554bfc3c2fff47ff7919c0d67bbf6c7dc38ab..b2d8becff10138ae3a1ee9a646a097236c5e999a 100644 --- a/src/block_alloc.h +++ b/src/block_alloc.h @@ -2,10 +2,11 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: block_alloc.h,v 1.63 2003/03/14 15:50:43 grubba Exp $ +|| $Id: block_alloc.h,v 1.64 2003/03/15 16:18:32 grubba Exp $ */ #undef PRE_INIT_BLOCK +#undef DO_PRE_INIT_BLOCK #undef INIT_BLOCK #undef EXIT_BLOCK #undef BLOCK_ALLOC @@ -23,11 +24,7 @@ /* Note: The block_alloc mutex is held while PRE_INIT_BLOCK runs. */ #define PRE_INIT_BLOCK(X) #define INIT_BLOCK(X) -#ifdef DEBUG_MALLOC -#define EXIT_BLOCK(X) MEMSET((X), 0x55, sizeof(*(X))) -#else #define EXIT_BLOCK(X) -#endif /* DEBUG_MALLOC */ #define COUNT_BLOCK(X) #define COUNT_OTHER() #define BLOCK_ALLOC_HSIZE_SHIFT 2 @@ -37,6 +34,13 @@ #define BLOCK_ALLOC_USED DO_IF_DMALLOC(real_used) DO_IF_NOT_DMALLOC(used) #endif +/* Invalidate the block as far as possible if running with dmalloc. + */ +#define DO_PRE_INIT_BLOCK(X) do { \ + DO_IF_DMALLOC(MEMSET((X), 0x55, sizeof(*(X)))); \ + PRE_INIT_BLOCK(X); \ + } while (0) + #ifndef PIKE_HASH_T /* Used to be size_t, but that led to performance problems * on 64-bit architectures without % on 64bit unsigned. @@ -122,12 +126,12 @@ static void PIKE_CONCAT(alloc_more_,DATA)(void) \ PIKE_CONCAT(DATA,_blocks)=n; \ PIKE_CONCAT(DATA,_free_blocks)=n; \ \ + DO_PRE_INIT_BLOCK( n->x ); \ n->x[0].BLOCK_ALLOC_NEXT=NULL; \ - PRE_INIT_BLOCK( n->x ); \ for(e=1;e<(BSIZE);e++) \ { \ + DO_PRE_INIT_BLOCK( (n->x+e) ); \ n->x[e].BLOCK_ALLOC_NEXT=(void *)&n->x[e-1]; \ - PRE_INIT_BLOCK( (n->x+e) ); \ } \ n->PIKE_CONCAT3(free_,DATA,s)=&n->x[(BSIZE)-1]; \ /* Mark the new blocks as unavailable for now... */ \ @@ -251,9 +255,9 @@ void PIKE_CONCAT(really_free_,DATA)(struct DATA *d) \ PIKE_CONCAT(DATA,_free_blocks) = blk; \ } \ \ + DO_PRE_INIT_BLOCK(d); \ d->BLOCK_ALLOC_NEXT = (void *)blk->PIKE_CONCAT3(free_,DATA,s); \ blk->PIKE_CONCAT3(free_,DATA,s)=d; \ - PRE_INIT_BLOCK(d); \ /* Mark block as unavailable. */ \ PIKE_MEM_NA(*d); \ \ diff --git a/src/pike_types.c b/src/pike_types.c index 8c2f7394a892f66a667601968b44819012f4d59b..947dd3741e16e8fbe90129c8be8bbb5c37743674 100644 --- a/src/pike_types.c +++ b/src/pike_types.c @@ -2,11 +2,11 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: pike_types.c,v 1.211 2003/03/14 15:50:46 grubba Exp $ +|| $Id: pike_types.c,v 1.212 2003/03/15 16:18:32 grubba Exp $ */ #include "global.h" -RCSID("$Id: pike_types.c,v 1.211 2003/03/14 15:50:46 grubba Exp $"); +RCSID("$Id: pike_types.c,v 1.212 2003/03/15 16:18:32 grubba Exp $"); #include <ctype.h> #include "svalue.h" #include "pike_types.h" @@ -219,6 +219,11 @@ static size_t pike_type_hash_size = 0; void debug_free_type(struct pike_type *t) { +#ifdef DEBUG_MALLOC + if (t == (struct pike_type *)(size_t)0x55555555) { + Pike_fatal("Freeing dead type.\n"); + } +#endif /* DEBUG_MALLOC */ loop: if (!sub_ref(t)) { unsigned INT32 hash = t->hash % pike_type_hash_size;