diff --git a/src/dmalloc.h b/src/dmalloc.h index dfb24d5c56e115eab017f8ff4495147a31d3b9f0..5d0626b43e62a7f89b87ee6f1b3f0335f4a3612f 100644 --- a/src/dmalloc.h +++ b/src/dmalloc.h @@ -1,5 +1,5 @@ /* - * $Id: dmalloc.h,v 1.9 1999/01/31 09:01:43 hubbe Exp $ + * $Id: dmalloc.h,v 1.10 1999/03/19 11:39:29 hubbe Exp $ */ extern char *debug_xalloc(long); @@ -33,6 +33,7 @@ void *debug_malloc_update_location(void *,const char *, int); #define debug_malloc_pass(X) debug_malloc_update_location((X),__FILE__,__LINE__) #define xalloc(X) ((char *)debug_malloc_touch(debug_xalloc(X))) void debug_malloc_dump_references(void *x); +#define dmalloc_touch(TYPE,X) ((TYPE)debug_malloc_update_location((X),__FILE__,__LINE__)) #else #define debug_malloc_dump_references(X) #define xalloc debug_xalloc @@ -41,4 +42,5 @@ void debug_malloc_dump_references(void *x); #define debug_malloc_update_location(X,Y,Z) (X) #define debug_malloc_touch(X) #define debug_malloc_pass(X) (X) +#define dmalloc_touch(TYPE,X) (X) #endif diff --git a/src/pike_memory.c b/src/pike_memory.c index 607fc0eec9b9a0797548aee8f0da2f81516411a1..5c9f531aa12e1fad52201ec0218474bf25513ed3 100644 --- a/src/pike_memory.c +++ b/src/pike_memory.c @@ -10,7 +10,7 @@ #include "pike_macros.h" #include "gc.h" -RCSID("$Id: pike_memory.c,v 1.34 1999/03/10 02:41:17 hubbe Exp $"); +RCSID("$Id: pike_memory.c,v 1.35 1999/03/19 11:39:30 hubbe Exp $"); /* strdup() is used by several modules, so let's provide it */ #ifndef HAVE_STRDUP @@ -636,8 +636,8 @@ int debug_malloc_check_all = 0; #define LHSIZE 1109891 #define FLSIZE 8803 #define DEBUG_MALLOC_PAD 8 -#define FREE_DELAY 1024 -#define MAX_UNFREE_MEM 1024*1024*16 +#define FREE_DELAY 4096 +#define MAX_UNFREE_MEM 1024*1024*32 static void *blocks_to_free[FREE_DELAY]; static unsigned int blocks_to_free_ptr=0; @@ -701,9 +701,12 @@ char *do_pad(char *mem, long size) void check_pad(struct memhdr *mh, int freeok) { + static int out_biking=0; long q,e; char *mem=mh->data; long size=mh->size; + if(out_biking) return; + if(size < 0) { if(!freeok) @@ -725,14 +728,16 @@ void check_pad(struct memhdr *mh, int freeok) q=(q<<13) ^ ~(q>>5); if(mem[e-DEBUG_MALLOC_PAD] != tmp) { + out_biking=1; fprintf(stderr,"Pre-padding overwritten for block at %p (size %ld) (e=%ld %d!=%d)!\n",mem, size, e, tmp, mem[e-DEBUG_MALLOC_PAD]); - dump_memhdr_locations(mh, 0); + describe(mem); abort(); } if(mem[size+e] != tmp) { + out_biking=1; fprintf(stderr,"Post-padding overwritten for block at %p (size %ld) (e=%ld %d!=%d)!\n",mem, size, e, tmp, mem[size+e]); - dump_memhdr_locations(mh, 0); + describe(mem); abort(); } } diff --git a/src/program.h b/src/program.h index 11aeb87e32e90e2325e1d195aa17238dbf108b39..8f54d34f9645c93afb742c3b5a0085f0ef4c1a8c 100644 --- a/src/program.h +++ b/src/program.h @@ -5,7 +5,7 @@ \*/ /* - * $Id: program.h,v 1.53 1999/03/17 21:51:59 hubbe Exp $ + * $Id: program.h,v 1.54 1999/03/19 11:39:49 hubbe Exp $ */ #ifndef PROGRAM_H #define PROGRAM_H @@ -229,14 +229,14 @@ struct program INT16 lfuns[NUM_LFUNS]; }; -#define INHERIT_FROM_PTR(P,X) ((debug_malloc_pass(P))->inherits + (debug_malloc_pass(X))->inherit_offset) -#define PROG_FROM_PTR(P,X) (debug_malloc_pass(INHERIT_FROM_PTR(P,X)->prog)) +#define INHERIT_FROM_PTR(P,X) (dmalloc_touch(struct program *,(P))->inherits + (X)->inherit_offset) +#define PROG_FROM_PTR(P,X) (dmalloc_touch(struct program *,INHERIT_FROM_PTR(P,X)->prog)) #define ID_FROM_PTR(P,X) (PROG_FROM_PTR(P,X)->identifiers+(X)->identifier_offset) #define INHERIT_FROM_INT(P,X) INHERIT_FROM_PTR(P,(P)->identifier_references+(X)) #define PROG_FROM_INT(P,X) PROG_FROM_PTR(P,(P)->identifier_references+(X)) #define ID_FROM_INT(P,X) ID_FROM_PTR(P,(P)->identifier_references+(X)) -#define FIND_LFUN(P,N) ((debug_malloc_pass(P))->flags & PROGRAM_FIXED?(debug_malloc_pass((P)->lfuns[(N)])):find_identifier(lfun_names[(N)],(P))) +#define FIND_LFUN(P,N) ( dmalloc_touch(struct program *,(P))->flags & PROGRAM_FIXED?((P)->lfuns[(N)]):find_identifier(lfun_names[(N)],(P)) ) #define free_program(p) do{ struct program *_=(p); debug_malloc_touch(_); if(!--_->refs) really_free_program(_); }while(0)