Branch: Tag:

2001-07-01

2001-07-01 18:17:30 by Martin Stjernholm <mast@lysator.liu.se>

Fixed bug where the gc sometimes failed to mark all things referenced
from live objects properly, which causes them to be garbed too early.

Rev: src/gc.c:1.162

30:      #include "block_alloc.h"    - RCSID("$Id: gc.c,v 1.161 2001/06/30 21:28:35 mast Exp $"); + RCSID("$Id: gc.c,v 1.162 2001/07/01 18:17:30 mast Exp $");      /* Run garbage collect approximately every time    * 20 percent of all arrays, objects and programs is
569:    fprintf(stderr, "**");    (void) VFPRINTF(stderr, fmt, args);    +  if (a) {    /* Temporarily jumping out of gc to avoid being catched in debug    * checks in describe(). */    Pike_in_gc = 0;
585:    fprintf(stderr,"** No marker found for this thing.\n");    }    Pike_in_gc = orig_gc_pass; +  } +     if (flags & 2)    fatal_after_gc = "Fatal in garbage collector.\n";    else
1171: Inside #if defined(PIKE_DEBUG)
   gc_check_all_objects();      #ifdef PIKE_DEBUG -  if(master_object) { -  found_where = " as master_object"; -  gc_external_mark2(master_object,0," &master_object"); -  } +  if(master_object) +  gc_external_mark2(master_object,0," as master_object");    {    extern struct mapping *builtin_constants; -  if(builtin_constants) { -  found_where = " as builtin_constants"; -  gc_external_mark2(builtin_constants,0," &builtin_constants"); +  if(builtin_constants) +  gc_external_mark2(builtin_constants,0," as builtin_constants");    } -  } +    #endif       found_where=0;
1699:    }    CYCLE_DEBUG_MSG(m, "gc_cycle_push, no live recurse");    } -  +     else { -  /* Nothing more to do. Unwind the live recursion. */ +  /* We'll get here eventually in the normal recursion. Pop off +  * the remaining live recurse frames for the last thing. */    int flags; -  CYCLE_DEBUG_MSG(m, "gc_cycle_push, live rec done"); -  do { +  CYCLE_DEBUG_MSG(m, "gc_cycle_push, no live recurse");    last->flags &= ~GC_LIVE_RECURSE; - #ifdef GC_CYCLE_DEBUG -  gc_cycle_indent -= 2; -  CYCLE_DEBUG_MSG(find_marker(gc_rec_last->data), -  "> gc_cycle_push, unwinding live"); - #endif +     while (1) {    struct gc_frame *l = gc_rec_top;   #ifdef PIKE_DEBUG
1725:    }    debug_really_free_gc_frame(l);    } -  last = find_marker(gc_rec_last->data); -  } while (last->flags & GC_LIVE_RECURSE); + #ifdef GC_CYCLE_DEBUG +  gc_cycle_indent -= 2; +  CYCLE_DEBUG_MSG(m, "> gc_cycle_push, unwound live rec"); + #endif    }       return 0;
1771:    if (p == gc_rec_last) break;    }   #ifdef PIKE_DEBUG -  if (p == gc_rec_last && !nonstrong_ref) -  gc_fatal(x, 0, "Only strong links in cycle.\n"); +  if (p == gc_rec_last && !nonstrong_ref) { +  fprintf(stderr, "Only strong links in cycle:\n"); +  for (p = NEXT(m->frame);; p = NEXT(p)) { +  describe(p->data); +  locate_references(p->data); +  if (p == gc_rec_last) break; +  fprintf(stderr, "========= next =========\n"); +  } +  gc_fatal(0, 0, "Only strong links in cycle.\n"); +  }   #endif    }   
2192: Inside #if defined(PIKE_DEBUG)
     #ifdef PIKE_DEBUG    if(master_object) -  gc_external_mark2(master_object,0," &master_object"); +  gc_external_mark2(master_object,0," as master_object");       {    extern struct mapping *builtin_constants;    if(builtin_constants) -  gc_external_mark2(builtin_constants,0," &builtin_constants"); +  gc_external_mark2(builtin_constants,0," as builtin_constants");    }   #endif   
2278:    "| %u weak references freed, %d more things to free,\n"    "| space for %u gc frames used\n",    cycle_checked, last_cycle, weak_freed, -  obj_count - delayed_freed, max_gc_frames)); +  delayed_freed - obj_count, max_gc_frames));    }       if (gc_ext_weak_refs) {
2301:    "| zap weak: freed %ld external weak refs, %lu internal still around,\n"    "| %d more things to free\n",    PTRDIFF_T_TO_LONG(to_free - gc_ext_weak_refs), -  SIZE_T_TO_ULONG(gc_ext_weak_refs), obj_count - delayed_freed)); +  SIZE_T_TO_ULONG(gc_ext_weak_refs), delayed_freed - obj_count));    }      #ifdef PIKE_DEBUG