diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2017-08-07 11:37:30 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2017-08-07 11:37:30 +0300 |
commit | 348bc2ba8d5556f4e655675b94e1b29e80b40fdc (patch) | |
tree | c5ab178daf2447e3678f1d5debf299c2d80a2472 /dbg_mlc.c | |
parent | 13e834307b2605b5669be5e90b24df9a93469f58 (diff) | |
download | bdwgc-348bc2ba8d5556f4e655675b94e1b29e80b40fdc.tar.gz |
Fix leak_test crash in print_callers if free() is redirected
* 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().
Diffstat (limited to 'dbg_mlc.c')
-rw-r--r-- | dbg_mlc.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -837,6 +837,14 @@ GC_API void GC_CALL GC_debug_free(void * p) 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. */ + if (!GC_is_heap_ptr(p)) return; +# endif ABORT_ARG1("Invalid pointer passed to free()", ": %p", p); } if ((ptr_t)p - (ptr_t)base != sizeof(oh)) { |