From a91a3ce76d9eae787e1f83cd6421e577fd55c625 Mon Sep 17 00:00:00 2001 From: Martin Stjernholm <mast@lysator.liu.se> Date: Tue, 24 Jan 2006 23:10:27 +1000 Subject: [PATCH] Warn for objects that get created during exit cleanup. Rev: src/dmalloc.h:1.55 Rev: src/module.c:1.37 Rev: src/object.c:1.269 Rev: src/pike_memory.c:1.173 --- src/dmalloc.h | 3 ++- src/module.c | 3 ++- src/object.c | 12 +++++++++++- src/pike_memory.c | 3 ++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/dmalloc.h b/src/dmalloc.h index f4c1687851..a7f6d99032 100644 --- a/src/dmalloc.h +++ b/src/dmalloc.h @@ -2,7 +2,7 @@ || 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: dmalloc.h,v 1.54 2006/01/24 11:57:41 mast Exp $ +|| $Id: dmalloc.h,v 1.55 2006/01/24 13:10:27 mast Exp $ */ #ifndef DMALLOC_H @@ -40,6 +40,7 @@ void gc_check_zapped (void *a, TYPE_T type, const char *file, int line); #ifdef DO_PIKE_CLEANUP extern int exit_with_cleanup; +extern int exit_cleanup_in_progress; #define DO_IF_PIKE_CLEANUP(X) X #else #define DO_IF_PIKE_CLEANUP(X) diff --git a/src/module.c b/src/module.c index 67fb26af4e..d420ef1067 100644 --- a/src/module.c +++ b/src/module.c @@ -2,7 +2,7 @@ || 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: module.c,v 1.36 2005/12/31 03:36:26 nilsson Exp $ +|| $Id: module.c,v 1.37 2006/01/24 13:10:27 mast Exp $ */ #include "global.h" @@ -354,6 +354,7 @@ void exit_modules(void) * always report destructed objects. We use the gc in a special mode * for this to get a reasonably sane destruct order. */ gc_destruct_everything = 1; + exit_cleanup_in_progress = 1; /* Warn about object creation from now on. */ count = do_gc (NULL, 1); while (count) { size_t new_count = do_gc (NULL, 1); diff --git a/src/object.c b/src/object.c index 0b0185c938..b3892e1090 100644 --- a/src/object.c +++ b/src/object.c @@ -2,7 +2,7 @@ || 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: object.c,v 1.268 2006/01/12 12:31:50 grubba Exp $ +|| $Id: object.c,v 1.269 2006/01/24 13:10:27 mast Exp $ */ #include "global.h" @@ -116,6 +116,16 @@ PMOD_EXPORT struct object *low_clone(struct program *p) GC_ALLOC(o); +#ifdef DO_PIKE_CLEANUP + if (exit_cleanup_in_progress) { + INT32 line; + struct pike_string *file = get_program_line (p, &line); + fprintf (stderr, + "Warning: Object %p created during exit cleanup from %s:%d\n", + o, file->str, line); + } +#endif + #ifdef DEBUG_MALLOC if(!debug_malloc_copy_names(o, p)) { diff --git a/src/pike_memory.c b/src/pike_memory.c index d95f46b72f..09fa0eeac5 100644 --- a/src/pike_memory.c +++ b/src/pike_memory.c @@ -2,7 +2,7 @@ || 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: pike_memory.c,v 1.172 2006/01/24 11:57:41 mast Exp $ +|| $Id: pike_memory.c,v 1.173 2006/01/24 13:10:27 mast Exp $ */ #include "global.h" @@ -825,6 +825,7 @@ int dmalloc_print_trace; #ifdef DO_PIKE_CLEANUP int exit_with_cleanup = 1; +int exit_cleanup_in_progress = 0; #endif #ifdef DEBUG_MALLOC -- GitLab