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.
+
+2011-04-09 Ivan Maidanski <ivmai@mail.ru>
+
* os_dep.c (GC_unix_sbrk_get_mem, GC_unix_get_mem): Don't define
for RTEMS.
* include/private/gcconfig.h (RTEMS): Add support for.
These define arguments influence the collector configuration:
-FIND_LEAK causes GC_find_leak to be initially set.
- This causes the collector to assume that all inaccessible
- objects should have been explicitly deallocated, and reports exceptions.
- Finalization and the test program are not usable in this mode.
+
+FIND_LEAK Causes GC_find_leak to be initially set. This causes the
+ collector to assume that all inaccessible objects should have been
+ explicitly deallocated, and reports exceptions. Finalization and the test
+ program are not usable in this mode.
+
+GC_ABORT_ON_LEAK Causes the application to be terminated once leaked or
+ smashed (corrupted on use-after-free) objects are found (after printing the
+ information about that objects).
SUNOS5SIGS Solaris-like signal handling. This is probably misnamed,
- since it really doesn't guarantee much more than Posix.
- Currently set only for Solaris2.X, HPUX, and DRSNX. Should
- probably be set for some other platforms.
+ since it really doesn't guarantee much more than POSIX. Currently set only
+ for Solaris2.X, HPUX, and DRSNX. Should probably be set for some other
+ platforms.
-PCR Set if the collector is being built as part of the Xerox
- Portable Common Runtime.
+PCR Set if the collector is being built as part of the Xerox Portable
+ Common Runtime.
-USE_COMPILER_TLS Assume the existence of __thread-style thread-local
- storage. Set automatically for thread-local allocation with
- the HP/UX vendor compiler. Usable with gcc on sufficiently
- up-to-date ELF platforms.
+USE_COMPILER_TLS Assume the existence of __thread-style thread-local storage.
+ Set automatically for thread-local allocation with the HP/UX vendor
+ compiler. Usable with gcc on sufficiently up-to-date ELF platforms.
IMPORTANT: Any of the _THREADS options must normally also be defined in
the client before including gc.h. This redefines thread primitives to
GC_INNER void GC_print_all_errors(void)
{
static GC_bool printing_errors = FALSE;
+ GC_bool have_errors;
unsigned i;
DCL_LOCK_STATE;
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) {
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;
}