(Cherry-pick commit
862f5a8 from 'release-7_4' branch.)
* dbg_mlc.c [REDIRECT_MALLOC && (GC_LINUX_THREADS || GC_SOLARIS_THREADS
|| MSWIN32 || NEED_CALLINFO && GC_HAVE_BUILTIN_BACKTRACE)]
(GC_debug_free): If the object is not in the GC heap then just return
(instead of ABORT).
* malloc.c [REDIRECT_MALLOC && NEED_CALLINFO
&& GC_HAVE_BUILTIN_BACKTRACE] (GC_free): If hhdr is null (i.e. the
object is not in the GC heap) then return without the object
deallocation; add comment.
* os_dep.c [NEED_CALLINFO && GC_HAVE_BUILTIN_BACKTRACE
&& !GC_BACKTRACE_SYMBOLS_BROKEN] (GC_print_callers): Adjust comment
for free().
base = GC_base(p);
if (base == 0) {
+# if defined(REDIRECT_MALLOC) \
+ && ((defined(NEED_CALLINFO) && defined(GC_HAVE_BUILTIN_BACKTRACE)) \
+ || defined(GC_LINUX_THREADS) || defined(GC_SOLARIS_THREADS) \
+ || defined(MSWIN32))
+ /* In some cases, we should ignore objects that do not belong */
+ /* to the GC heap. See the comment in GC_free. */
+ bottom_index *bi;
+
+ GET_BI(p, bi);
+ if (HDR_FROM_BI(bi, p) == 0) return;
+# endif
GC_err_printf("Attempt to free invalid pointer %p\n", p);
ABORT("Invalid pointer passed to free()");
}
h = HBLKPTR(p);
hhdr = HDR(h);
# if defined(REDIRECT_MALLOC) && \
- (defined(GC_SOLARIS_THREADS) || defined(GC_LINUX_THREADS) \
+ ((defined(NEED_CALLINFO) && defined(GC_HAVE_BUILTIN_BACKTRACE)) \
+ || defined(GC_SOLARIS_THREADS) || defined(GC_LINUX_THREADS) \
|| defined(MSWIN32))
+ /* This might be called indirectly by GC_print_callers to free */
+ /* the result of backtrace_symbols. */
/* For Solaris, we have to redirect malloc calls during */
/* initialization. For the others, this seems to happen */
/* implicitly. */
GC_err_printf("\t\t%s\n", name);
# if defined(GC_HAVE_BUILTIN_BACKTRACE) \
&& !defined(GC_BACKTRACE_SYMBOLS_BROKEN)
- free(sym_name); /* May call GC_free; that's OK */
+ free(sym_name); /* May call GC_[debug_]free; that's OK */
# endif
}
}