From: Bart Van Assche Date: Sat, 12 Mar 2011 12:43:39 +0000 (+0000) Subject: DRD: Always invoke VG_(cli_free)() before the stop_using_mem callback. X-Git-Tag: svn/VALGRIND_3_7_0~596 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ced34515323a2b87c37cd85cf7a47fad78a3ef5;p=thirdparty%2Fvalgrind.git DRD: Always invoke VG_(cli_free)() before the stop_using_mem callback. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11633 --- diff --git a/drd/drd_clientreq.c b/drd/drd_clientreq.c index 8e9eb82565..a64bd852e8 100644 --- a/drd/drd_clientreq.c +++ b/drd/drd_clientreq.c @@ -81,7 +81,7 @@ static Bool handle_client_request(ThreadId vg_tid, UWord* arg, UWord* ret) 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)(), diff --git a/drd/drd_malloc_wrappers.c b/drd/drd_malloc_wrappers.c index 6eeffdb269..7b594ffc70 100644 --- a/drd/drd_malloc_wrappers.c +++ b/drd/drd_malloc_wrappers.c @@ -109,19 +109,18 @@ void DRD_(malloclike_block)(const ThreadId tid, const Addr p, const SizeT size) static void handle_free(ThreadId tid, void* p) { - tl_assert(p); + Bool success; - if (DRD_(freelike_block)(tid, (Addr)p)) - VG_(cli_free)(p); - else - tl_assert(False); + tl_assert(p); + 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 @@ Bool DRD_(freelike_block)(const ThreadId tid, const Addr p) 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); diff --git a/drd/drd_malloc_wrappers.h b/drd/drd_malloc_wrappers.h index 2f9c2cece6..d41464d30e 100644 --- a/drd/drd_malloc_wrappers.h +++ b/drd/drd_malloc_wrappers.h @@ -38,7 +38,7 @@ typedef void (*StopUsingMem)(const Addr a1, const SizeT len); 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,