summaryrefslogtreecommitdiff
path: root/reclaim.c
diff options
context:
space:
mode:
authorivmai <ivmai>2011-04-09 15:42:08 +0200
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:57 +0200
commit46191afd5688188b44d6ef60d917b361dd44d765 (patch)
treec8ca051a56c60b66af01f7ce927571eef394578c /reclaim.c
parent3d088080ba7330addad9069577fcf646c5c4c809 (diff)
2011-04-09 Ivan Maidanski <ivmai@mail.ru>
* reclaim.c (GC_print_all_errors): Recognize new GC_ABORT_ON_LEAK macro and environment variable; abort if any error has been printed provided the environment variable (or macro) is set. * doc/README.environment (GC_ABORT_ON_LEAK): Document. * doc/README.macros (GC_ABORT_ON_LEAK): Ditto. * doc/README.macros (FIND_LEAK, SUNOS5SIGS, PCR, USE_COMPILER_TLS): Reformat the text.
Diffstat (limited to 'reclaim.c')
-rw-r--r--reclaim.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/reclaim.c b/reclaim.c
index e17d374..efade9b 100644
--- a/reclaim.c
+++ b/reclaim.c
@@ -57,6 +57,7 @@ STATIC void GC_add_leaked(ptr_t leaked)
GC_INNER void GC_print_all_errors(void)
{
static GC_bool printing_errors = FALSE;
+ GC_bool have_errors;
unsigned i;
DCL_LOCK_STATE;
@@ -65,9 +66,16 @@ GC_INNER void GC_print_all_errors(void)
UNLOCK();
return;
}
+ have_errors = GC_have_errors;
printing_errors = TRUE;
UNLOCK();
- if (GC_debugging_started) GC_print_all_smashed();
+
+ if (GC_debugging_started) {
+ GC_print_all_smashed();
+ } else {
+ have_errors = FALSE;
+ }
+
for (i = 0; i < GC_n_leaked; ++i) {
ptr_t p = GC_leaked[i];
if (HDR(p) -> hb_obj_kind == PTRFREE) {
@@ -79,8 +87,18 @@ GC_INNER void GC_print_all_errors(void)
GC_err_printf("\n");
GC_free(p);
GC_leaked[i] = 0;
+ have_errors = TRUE;
}
GC_n_leaked = 0;
+
+ if (have_errors
+# ifndef GC_ABORT_ON_LEAK
+ && GETENV("GC_ABORT_ON_LEAK") != NULL
+# endif
+ ) {
+ ABORT("Leaked or smashed objects encountered");
+ }
+
printing_errors = FALSE;
}