Branch: Tag:

2008-08-26

2008-08-26 16:13:05 by Martin Stjernholm <mast@lysator.liu.se>

Another attempt to fix the "external refs after unregister" debug
check.

Rev: src/program.c:1.750

2:   || 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: program.c,v 1.749 2008/08/18 15:18:18 mast Exp $ + || $Id: program.c,v 1.750 2008/08/26 16:13:05 mast Exp $   */      #include "global.h"
8050:    if(delayed && c->target)    {    struct program *p = c->target; +     /* Free the constants in the failed program, to untangle the    * cyclic references we might have to this program, typically    * in parent pointers in nested classes. */
8073:    SAFE_APPLY_MASTER("unregister",1);    pop_stack();    -  /* Free the target here to avoid false alarms in the debug check -  * below. */ +  { + #ifdef PIKE_DEBUG +  int refs = p->refs; + #endif +  +  /* Free the target here to avoid false alarms in the debug +  * check below. */    free_program (c->target);    c->target = NULL;      #ifdef PIKE_DEBUG -  if (p->refs > 1) { +  if (refs > 1) {    /* Other programs can have indexed out constants from p, which    * might be broken themselves and/or keep references to p    * through the parent pointer. We should find all those other    * programs and invalidate them too, but how can that be done?    * The whole delayed compilation thingie is icky icky icky... :P    * /mast */ -  fprintf(stderr, "Warning: Program still got %d " -  "external refs after unregister:\n", p->refs - 1); +  fprintf(stderr, "Warning: Program %p still got %d " +  "external refs after unregister:\n", p, p->refs);    locate_references(p); -  +  fprintf (stderr, "Describing program:\n", p); +  describe_something (p, T_PROGRAM, 0, 0, 0, NULL);    }   #endif    }    } -  +  }    else    {    if (c->placeholder)