pike.git / src / gc.c

version» Context lines:

pike.git/src/gc.c:22:   #include "time_stuff.h"   #include "constants.h"   #include "interpret.h"      #include "gc.h"   #include "main.h"   #include <math.h>      #include "block_alloc.h"    - RCSID("$Id: gc.c,v 1.55 2000/04/13 00:50:16 hubbe Exp $"); + RCSID("$Id: gc.c,v 1.56 2000/04/13 02:11:25 hubbe Exp $");      /* Run garbage collect approximate every time we have    * 20 percent of all arrays, objects and programs is    * garbage.    */      #define GC_CONST 20   #define MIN_ALLOC_THRESHOLD 1000   #define MAX_ALLOC_THRESHOLD 10000000   #define MULTIPLIER 0.9
pike.git/src/gc.c:122: Inside #if defined(PIKE_DEBUG)
      return T_UNKNOWN;   }      void *check_for =0;   static char *found_where="";   static void *found_in=0;   static int found_in_type=0;   void *gc_svalue_location=0;    + #ifdef PIKE_DEBUG + static char *fatal_after_gc=0; + #endif +  +    void describe_location(void *memblock, int type, void *location)   {    struct program *p;    if(!location) return;   /* fprintf(stderr,"**Location of (short) svalue: %p\n",location); */      #ifdef DEBUG_MALLOC    if(memblock == 0 || type == -1)    {    extern void *dmalloc_find_memblock_base(void *);
pike.git/src/gc.c:532: Inside #if defined(PIKE_DEBUG)
  #ifdef PIKE_DEBUG    if(check_for)    {    if(check_for == a)    {    gdb_gc_stop_here(a);    }       if(check_for == (void *)1 && gc_do_free(a))    { -  fprintf(stderr,"Reference to object to free in referenced object!\n"); +  struct marker *m=get_marker(a); +  fprintf(stderr,"**Reference to object to free in referenced object!\n"); +  fprintf(stderr," has %ld references, while gc() found %ld + %ld external.\n",(long)*(INT32 *)a,(long)m->refs,(long)m->xrefs);    describe(a);    locate_references(a); -  fatal("Reference to object to free in referenced object!\n"); -  return 0; +  fprintf(stderr,"##### Continuing search for more bugs....\n"); +  fatal_after_gc="Reference to object to free in referenced object!\n";    }    return 0;    }   #endif    return add_ref(get_marker(a));   }      static void init_gc(void)   {   #if 0
pike.git/src/gc.c:692: Inside #if defined(PIKE_DEBUG)
   if(where) found_where=where;    if(in) found_in=in;       gdb_gc_stop_here(a);       found_where=tmp;    found_in=tmp2;       return 1;    } +  +  if(check_for == (void *)1 && gc_do_free(a)) +  { +  struct marker *m=get_marker(a); +  fprintf(stderr,"EXTERNAL Reference to object to free%s!\n",in?in:""); +  fprintf(stderr," has %ld references, while gc() found %ld + %ld external.\n",(long)*(INT32 *)a,(long)m->refs,(long)m->xrefs); +  if(where) describe_location(0,T_UNKNOWN,where); +  describe(a); +  locate_references(a); +  fprintf(stderr,"##### Continuing search for more bugs....\n"); +  fatal_after_gc="EXTERNAL Reference to object to free.\n"; +  } +     return 0;    }    m=get_marker(a);    m->xrefs++;    m->flags|=GC_XREFERENCED;    gc_is_referenced(a);    return 0;   }   #endif   
pike.git/src/gc.c:765:    gc_evaluator_callback=0;    }       tmp2=num_objects;      #ifdef PIKE_DEBUG    if(t_flag)    fprintf(stderr,"Garbage collecting ... ");    if(num_objects < 0)    fatal("Panic, less than zero objects!\n"); -  -  +    #endif       last_gc=TIME(0);       multiplier=pow(MULTIPLIER, (double) num_allocs / (double) alloc_threshold);    objects_alloced*=multiplier;    objects_alloced += (double) num_allocs;       objects_freed*=multiplier;    objects_freed += (double) num_objects;
pike.git/src/gc.c:822:    check_for=(void *)1;   #endif    /* Now we free the unused stuff */    gc_free_all_unreferenced_arrays();    gc_free_all_unreferenced_multisets();    gc_free_all_unreferenced_mappings();    gc_free_all_unreferenced_programs();    gc_free_all_unreferenced_objects();      #ifdef PIKE_DEBUG +     check_for=0; -  +  if(fatal_after_gc) fatal(fatal_after_gc);   #endif       exit_gc();       destruct_objects_to_destruct();       objects_freed -= (double) num_objects;       tmp=(double)num_objects;    tmp=tmp * GC_CONST/100.0 * (objects_alloced+1.0) / (objects_freed+1.0);