Do you know whether what I want to do is possible with Valgrind, or are
you just offering generic advice? Neither of the freelist options
(freelist-vol and freelist-big-blocks) seem related, and indeed,
changing them doesn't affect Valgrind's output on either your test
program or J. I'm well aware that if I read all of Valgrind's source
code I will eventually determine whether it has the option that I want,
but that is a tall order just to be able to use the program.

>From my perspective I have attempted to use Valgrind as intended, and it
fails to provide the single most important piece of information for
diagnosing a use-after-free error. I'm having difficulty understanding
why anyone would even find the current output useful--it simply states
that the offending block was allocated from the memory pool. The actual
information is clearly accessible to Valgrind, and it refuses to show
it! Even if this is only the default behavior, it strikes me as
completely insane.

Marshall

On Thu, May 26, 2016 at 09:27:28PM -0700, John Reiser wrote:
> =====recently.c
> #include "valgrind/valgrind.h"
> #include <stdlib.h>
> #include <string.h>
> 
> int main()
> {
>      int *const m0 = malloc (1<<16);
>      VALGRIND_CREATE_MEMPOOL(m0, (1<<16), 0);  // a new pool inside a 
> malloc()ed block
> 
>      int *const m1 = (4368/sizeof(int)) + m0;  // point into the interior of 
> the pool
>      VALGRIND_MEMPOOL_ALLOC(m0, m1, 16);  // "allocate" a block of 16 bytes 
> from the pool
>      VALGRIND_MEMPOOL_FREE(m0, m1);  // free the allocated block immediately
>      memset(m1, 0, 16);  // [error] write into the free()d block
> 
>      return 0;
> }
> =====
> 
> ==2668== Invalid write of size 8
> ==2668==    at 0x4C2EFDF: memset (in 
> /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==2668==    by 0x40090B: main (recently.c:13)
> ==2668==  Address 0x51f7150 is 4,368 bytes inside a recently re-allocated 
> block of size 65,536 alloc'd
> ==2668==    at 0x4C28C50: malloc (in 
> /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==2668==    by 0x4007BA: main (recently.c:7)
> 
> So valgrind is trying to say that memset is writing into a free()d block,
> and that the corresponding allocation was moderately recent.
> Consult "valgrind --help  |  grep freelist" for hints,
> then refer to the documentation or the source code.
> 
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are 
> consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
> J-Flow, sFlow and other flows. Make informed decisions using capacity 
> planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
> _______________________________________________
> Valgrind-users mailing list
> Valgrind-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/valgrind-users

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to