On 26/01/2021 09:32, Matthias Apitz wrote:

So far so good. What would have helped me is that vg could print in its
replacement functions for memmove(3) ... (vg_replace_strmem.c:1270)
the provided pointers and other args, and as well part of the src
buffer. For sure vg knows exactly these values to watch the illegal
memory access.

If the memory is uninitialised then printing it's contents
shouldn't really be useful as they will have no meaning...

Presumably it was partially initialised in this case but it
sounds like quite an edge case and it's easy enough to add
some custom debugging to your code when it does help in cases
like this. I'm not clear if you just printed everything but
you can conditionalise it to only print the failing case:

  if ( VALGRIND_CHECK_MEM_IS_DEFINED( src, n ) )
  {
    fprintf( stderr, "ERROR: %.*s\n", n, src );
  }

if you want to get really clever you can limit it to printing
the valid part:

  const char *fail = VALGRIND_CHECK_MEM_IS_DEFINED( src, n );

  if ( fail )
  {
    fprintf( stderr, "ERROR: %.*s\n", fail - src, src );
  }

Tom

--
Tom Hughes (t...@compton.nu)
http://compton.nu/


_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to