|
From: <sv...@va...> - 2011-03-12 12:43:46
|
Author: bart
Date: 2011-03-12 12:43:39 +0000 (Sat, 12 Mar 2011)
New Revision: 11633
Log:
DRD: Always invoke VG_(cli_free)() before the stop_using_mem callback.
Modified:
trunk/drd/drd_clientreq.c
trunk/drd/drd_malloc_wrappers.c
trunk/drd/drd_malloc_wrappers.h
Modified: trunk/drd/drd_clientreq.c
===================================================================
--- trunk/drd/drd_clientreq.c 2011-03-12 12:37:46 UTC (rev 11632)
+++ trunk/drd/drd_clientreq.c 2011-03-12 12:43:39 UTC (rev 11633)
@@ -81,7 +81,7 @@
break;
case VG_USERREQ__FREELIKE_BLOCK:
- if (arg[1] && ! DRD_(freelike_block)(vg_tid, arg[1]/*addr*/))
+ if (arg[1] && ! DRD_(freelike_block)(vg_tid, arg[1]/*addr*/, False))
{
GenericErrInfo GEI = {
.tid = DRD_(thread_get_running_tid)(),
Modified: trunk/drd/drd_malloc_wrappers.c
===================================================================
--- trunk/drd/drd_malloc_wrappers.c 2011-03-12 12:37:46 UTC (rev 11632)
+++ trunk/drd/drd_malloc_wrappers.c 2011-03-12 12:43:39 UTC (rev 11633)
@@ -109,19 +109,18 @@
static void handle_free(ThreadId tid, void* p)
{
+ Bool success;
+
tl_assert(p);
-
- if (DRD_(freelike_block)(tid, (Addr)p))
- VG_(cli_free)(p);
- else
- tl_assert(False);
+ success = DRD_(freelike_block)(tid, (Addr)p, True);
+ tl_assert(success);
}
/**
* Remove the information that was stored by DRD_(malloclike_block)() about
* a memory block.
*/
-Bool DRD_(freelike_block)(const ThreadId tid, const Addr p)
+Bool DRD_(freelike_block)(const ThreadId tid, const Addr p, const Bool dealloc)
{
DRD_Chunk* mc;
@@ -133,6 +132,8 @@
if (mc)
{
tl_assert(p == mc->data);
+ if (dealloc)
+ VG_(cli_free)((void*)p);
if (mc->size > 0)
s_stop_using_mem_callback(mc->data, mc->size);
VG_(free)(mc);
Modified: trunk/drd/drd_malloc_wrappers.h
===================================================================
--- trunk/drd/drd_malloc_wrappers.h 2011-03-12 12:37:46 UTC (rev 11632)
+++ trunk/drd/drd_malloc_wrappers.h 2011-03-12 12:43:39 UTC (rev 11633)
@@ -38,7 +38,7 @@
void DRD_(register_malloc_wrappers)(const StartUsingMem start_callback,
const StopUsingMem stop_callback);
void DRD_(malloclike_block)(const ThreadId tid, const Addr p, const SizeT size);
-Bool DRD_(freelike_block)(const ThreadId tid, const Addr p);
+Bool DRD_(freelike_block)(const ThreadId tid, const Addr p, const Bool dealloc);
Bool DRD_(heap_addrinfo)(Addr const a,
Addr* const data,
SizeT* const size,
|