|
From: Philippe W. <phi...@sk...> - 2012-03-07 20:56:13
|
I investigated why an outer memcheck does not detect a problem in an inner valgrind for the following (even with red zones): p = VG_(malloc(10)); p[-1] = 'a'; This is because VALGRIND_MALLOCLIKE_BLOCK does not make the red zone non addressable (so this also happens for normal clients using VALGRIND_MALLOCLIKE_BLOCK). The test memcheck/tests/custom_alloc.c verifies that writing to the red zone causes an error. It only succeeds because the superblock in this test is marked non addressable by custom_alloc.c, before it starts to allocate smaller blocks from it. It is not clear to me if it is the client or valgrind/memcheck which should ensure red zones are non addressable: VALGRIND_MALLOCLIKE_BLOCK does not take that in charge but VALGRIND_FREELIKE_BLOCK is taking it in charge. Either valgrind.h comments about VALGRIND_MALLOCLIKE_BLOCK should clarify that the caller has to mark red zones as non addressable, or a fix in memcheck is to be done. Any opinion/feedback ? (I am more attracted by the fix in memcheck). Philippe |