|
From: Erdem G. <zu...@ya...> - 2004-12-06 10:14:32
|
Thank you for advice, I decided to wait for your
solution.
Meanwhile I think I found a bug in find_addr function
which
is called from client_perm_maybe_describe.
find_addr function calls VG_(addr_is_in_block) which
use VG_(vg_malloc_redzone_szB).
I think this is wrong for memory pools, it must use
redzone value
for that memory pool.
So I make this hack:
static UInt ErdRzB;/***************ONE*/
static Bool find_addr(VgHashNode* sh_ch, void* ap)
{
MAC_Chunk *m = (MAC_Chunk*)sh_ch;
Addr a = *(Addr*)ap;
return (m->data - ErdRzB <= a
&& a < m->data + m->size + ErdRzB
);/*************TWO*/
}
Bool MC_(client_perm_maybe_describe)( Addr a,
AddrInfo* ai )
{
UInt i;
/* VG_(printf)("try to identify %d\n", a); */
/* Perhaps it's a general block ? */
for (i = 0; i < vg_cgb_used; i++) {
if (vg_cgbs[i].kind == CG_NotInUse)
continue;
if (VG_(addr_is_in_block)(a, vg_cgbs[i].start,
vg_cgbs[i].size)) {
MAC_Mempool **d, *mp;
/* OK - maybe it's a mempool, too? */
mp =
(MAC_Mempool*)VG_(HT_get_node)(MAC_(mempool_list),
(UInt)vg_cgbs[i].start,
(VgHashNode***)&d);
if(mp != NULL) {
if(mp->chunks != NULL) {
MAC_Chunk *mc;
ErdRzB =
mp->rzB;/*********************THREE*/
mc =
(MAC_Chunk*)VG_(HT_first_match)(mp->chunks,
find_addr, &a);
....
Now I have a loop in my code to find non-free chunk.
When a chunk found it tries to VALGRIND_MEMPOOL_FREE(
mypool, chunkaddr
+ 1 )
and valrind report this as a 'invalid free' error.
So I get correct address reports for un-freed blocks.
Robert Walsh wrote:
>>I use
>>VALGRIND_CREATE_MEMPOOL
>>VALGRIND_MEMPOOL_ALLOC
>>VALGRIND_MEMPOOL_FREE
>>macros for my memory pool.
>>
>>I want to report un-freed allocations at the exit
but
>>I can't find a way.
>>
>>
>
>Yeah, it doesn't do that right now. I suppose it
would be useful. I'll
>try allocate some time before the end of the year to
get this done, but
>if you're in a hurry, you might want to try hacking
on it yourself.
>Right now, MAC_(do_detect_memory_leaks) in
mac_leakcheck.c only looks at
>the stuff attached to MAC_(malloc_list), which is a
hash table of
>regular (i.e. non-mempool) allocated memory. This
would also need to
>look at MAC_(mempool_list), which is a hash table of
MAC_Mempool
>structures. Each structure contains a "chunks"
member, which is a hash
>table of allocations in that memory pool. You'd need
to search each one
>of these, too.
>
>Regards,
> Robert.
>
>
>
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo
|