2004-04-18
2004-04-18 02:16:06 by Martin Stjernholm <mast@lysator.liu.se>
-
4fab5f45f59af41f8a04567aac6d0455fd16b5b8
(48 lines)
(+37/-11)
[
Show
| Annotate
]
Branch: 7.9
Improved debug during cleanup: If there are internal refs that the gc don't
know about it will free them during the leak report. When they then are
freed from their real places later on, they will run out of refs. Therefore
the debug now prints all locations the leaked objects are freed from.
Rev: src/array.h:1.59
Rev: src/dmalloc.h:1.50
Rev: src/gc.c:1.253
Rev: src/gc.h:1.112
Rev: src/main.c:1.200
Rev: src/mapping.h:1.54
Rev: src/multiset.h:1.34
Rev: src/object.h:1.82
Rev: src/program.c:1.563
Rev: src/program.h:1.202
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: gc.c,v 1.252 2004/04/17 23:35:53 mast Exp $
+ || $Id: gc.c,v 1.253 2004/04/18 02:16:05 mast Exp $
*/
#include "global.h"
33:
#include "block_alloc.h"
- RCSID("$Id: gc.c,v 1.252 2004/04/17 23:35:53 mast Exp $");
+ RCSID("$Id: gc.c,v 1.253 2004/04/18 02:16:05 mast Exp $");
int gc_enabled = 1;
321:
if(safe_debug_findstring((struct pike_string *)something))
return T_STRING;
+ if (pike_type_hash)
for (i = 0; i < pike_type_hash_size; i++)
for (t = pike_type_hash[i]; t; t = t->next)
if (t == (struct pike_type *) something)
1528: Inside #if defined(DO_PIKE_CLEANUP)
{
#ifdef DO_PIKE_CLEANUP
size_t e=0;
- struct marker *h;
+
+ if (gc_keep_markers) {
+ /* Carry over any GC_CLEANUP_FREED flags but reinitialize them
+ * otherwise. */
+ for(e=0;e<marker_hash_table_size;e++) {
+ struct marker *m;
+ for (m = marker_hash_table[e]; m; m = m->next) {
+ m->flags &= GC_CLEANUP_FREED;
+ m->refs = m->weak_refs = m->xrefs = 0;
+ m->saved_refs = -1;
+ m->frame = 0;
+ }
+ }
+ return;
+ }
+
for(e=0;e<marker_hash_table_size;e++)
while(marker_hash_table[e])
remove_marker(marker_hash_table[e]->data);
1536:
exit_marker_hash();
}
-
+
static void init_gc(void)
{
#ifdef PIKE_DEBUG
1544: Inside #if defined(PIKE_DEBUG)
/* The marker hash table is left around after a previous gc if
* gc_keep_markers is set. */
if (marker_hash_table) cleanup_markers();
+ if (!marker_hash_table)
#endif
-
+
low_init_marker_hash(num_objects);
get_marker(rec_list.data); /* Used to simplify fencepost conditions. */
#ifdef PIKE_DEBUG
1553:
#endif
}
- static void exit_gc(void)
+ void exit_gc(void)
{
if (gc_evaluator_callback) {
remove_callback(gc_evaluator_callback);
1764: Inside #if defined(PIKE_DEBUG)
return 0;
}
+ #ifdef DO_PIKE_CLEANUP
+ void gc_check_zapped (void *a, TYPE_T type, const char *file, int line)
+ {
+ struct marker *m = find_marker (a);
+ if (m && (m->flags & GC_CLEANUP_FREED))
+ fprintf (stderr, "Free of leaked %s %p from %s:%d, %d refs remaining\n",
+ get_name_of_type (type), a, file, line, *(INT32 *)a - 1);
+ }
+ #endif
+
void debug_really_free_gc_frame(struct gc_frame *l)
{
if (l->frameflags & GC_LINK_FREED)