diff --git a/src/dmalloc.h b/src/dmalloc.h
index f4c1687851eec2c59123469ececd12771345dcd6..a7f6d99032c0475f045401bf514ce366335f3626 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 67fb26af4e241819f056a525e94ca6dbf021463a..d420ef1067e2ffc63f400705f130a18e3578b13e 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 0b0185c938b485bf40a36bdeecab3541d6699d51..b3892e1090ea22759d28fa721e972ae0a79d8948 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 d95f46b72f2725df2169aac7b8f07e47c7dbe834..09fa0eeac555572e995ab0966adb5c46fa944579 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