Closed GoogleCodeExporter closed 9 years ago
Thanks for tracking down the problem and providing a fix. There's an alternate
fix,
which is to change the line
free(malloc(1))
in TCMallocGuard to say
do_free(do_malloc(1))
instead. Do you mind testing that to see if that also works to fix the
problems you
were seeing? We'll debate here which is better, but get one or the other into
the
next release.
Original comment by csilv...@gmail.com
on 7 Jan 2010 at 2:22
Either prevents the crash. The do_free(do_malloc(1)); method does require
prototypes
as those functions aren't declared until later in the file.
+++ tcmalloc.cc 2010-01-07 08:29:01.000000000 -0600
@@ -198,6 +198,8 @@ size_t InvalidGetAllocatedSize(void* ptr
CRASH("Attempt to get the size of an invalid pointer: %p\n", ptr);
return 0;
}
+inline void* do_malloc(size_t size);
+inline void do_free(void* ptr);
} // unnamed namespace
// Extract interesting stats
Original comment by da...@fries.net
on 7 Jan 2010 at 2:35
On thinking about this more, I'm wondering why you'r eusing do_malloc/do_free
instead
of tc_malloc/tc_free. Those were the routines that were written with your
use-case in
mind: using tcmalloc for some allocations but not others. Is there any reason
you
can't use those?
If so, then the right fix (I think), will be to change TCMallocGuard to call
tc_free(tc_mnalloc(1)) rather than malloc/free.
Original comment by csilv...@gmail.com
on 7 Jan 2010 at 4:45
I tc_malloc or tc_free weren't available in the 1.2 release we started using.
They
are appreciated and will be used in the future as part of upgraded tcmalloc.
Original comment by da...@fries.net
on 16 Jan 2010 at 7:26
OK, makes sense. My plan is to change TCMallocGuard to call
tc_free(tc_malloc()) in
the next release, so if/when you upgrade to a new release, you should be able to
replace your calls from do_* to tc_*, and that should fix the problem for you.
Original comment by csilv...@gmail.com
on 17 Jan 2010 at 3:56
This is done in perftools 1.5, just released.
Original comment by csilv...@gmail.com
on 20 Jan 2010 at 11:05
Original issue reported on code.google.com by
da...@fries.net
on 6 Jan 2010 at 4:39Attachments: