diff --git a/src/interpret.c b/src/interpret.c index bc920af9d941490ffecd7446b7fdcae71815ac64..73f218367ca83b4c15ff96e0716a7c460c81005c 100644 --- a/src/interpret.c +++ b/src/interpret.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: interpret.c,v 1.342 2003/12/09 15:39:45 grubba Exp $ +|| $Id: interpret.c,v 1.343 2004/02/09 22:02:56 mast Exp $ */ #include "global.h" -RCSID("$Id: interpret.c,v 1.342 2003/12/09 15:39:45 grubba Exp $"); +RCSID("$Id: interpret.c,v 1.343 2004/02/09 22:02:56 mast Exp $"); #include "interpret.h" #include "object.h" #include "program.h" @@ -542,7 +542,7 @@ static struct inherit dummy_inherit PMOD_EXPORT void find_external_context(struct external_variable_context *loc, int depth) { - struct program *p = loc->o->prog; + struct program *p; TRACE((4, "-find_external_context(%d, inherit=%ld)\n", depth, DO_NOT_WARN((long)(loc->o->prog ? loc->inherit - loc->o->prog->inherits : 0)))); @@ -552,6 +552,23 @@ PMOD_EXPORT void find_external_context(struct external_variable_context *loc, Pike_fatal("No object\n"); #endif + p = loc->o->prog; + +#ifdef DEBUG_MALLOC + if (loc->o->refs == 0x55555555) { + fprintf(stderr, "The object %p has been zapped!\n", loc->o); + describe(p); + Pike_fatal("Object zapping detected.\n"); + } + if (p && p->refs == 0x55555555) { + fprintf(stderr, "The program %p has been zapped!\n", p); + describe(p); + fprintf(stderr, "Which taken from the object %p\n", loc->o); + describe(loc->o); + Pike_fatal("Looks like the program %p has been zapped!\n", p); + } +#endif /* DEBUG_MALLOC */ + while(--depth>=0) { struct inherit *inh = loc->inherit; @@ -638,16 +655,16 @@ PMOD_EXPORT void find_external_context(struct external_variable_context *loc, Pike_fatal("Looks like the program %p has been zapped!\n", p); } #endif /* DEBUG_MALLOC */ - + + if (p) { #ifdef PIKE_DEBUG - if(loc->parent_identifier < 0 || - (p && loc->parent_identifier > p->num_identifier_references)) - Pike_fatal("Identifier out of range, loc->parent_identifer=%d!\n", - loc->parent_identifier); + if(loc->parent_identifier < 0 || + loc->parent_identifier > p->num_identifier_references) + Pike_fatal("Identifier out of range, loc->parent_identifer=%d!\n", + loc->parent_identifier); #endif - - if (p) loc->inherit=INHERIT_FROM_INT(p, loc->parent_identifier); + } else /* Return a valid pointer to a dummy inherit for the convenience * of the caller. Identifier offsets will be bogus but it'll