Hi

I am working on a custom memory allocator, and I'm currently trying to
integrate Valgrind with it, so that we can use memcheck with it. I
think I have understood properly the documentation, and I have a
correct implementation. But there is still one issue remaining.

In our memory allocator, memory chunks can be allocated in one pool and
freed in another (different) pool. This is no problem, because chunks
have a specific size, and they are pushed to a queue of free chunks.

This, when integrated with Valgrind, causes that the pools specified
when calling VALGRIND_MEMPOOL_ALLOC and VALGRIND_MEMPOOL_FREE are not
the same. This does not give any error nor warning (maybe it should?).
Later, the chunk is reused in the new pool, and when Valgrind checks
for overlaps, it outputs this:

Block 0x6f17a00..0x6f17bff overlaps with block 0x6f17a00..0x6f17bff

Which makes complete sense: the same chunk has been used in two pools
(although never "at the same time").

The chunks come with no information to the allocator, so there is no
easy way of checking which was the original pool. If this was the case,
I could just do a FREE from the original pool.

Is there any other way to tell Valgrind that one chunk has swapped
pools?

(If something seems wrong with my logic, tell me, because I may have
misundertood the documentation. I'm writing this because the output of
Valgrind fits with what I think it's happening).

Thanks
Marc

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to