|
From: Philippe W. <phi...@sk...> - 2012-02-19 18:30:03
|
For working on multi-threaded valgrind, I am trying helgrind or drd
on a none tool. This does not work.
>From what I have experimented, any outer tool that redirects
malloc/free/... will not work with an inner tool that does not
redirect malloc/free/...
Typically, an outer memcheck/helgrind/drd/... cannot run an
inner none/callgrind/cachegrind
(confirmed by doing all combinations. They all fail for similar
reasons. The below discusses helgrind+none more in details).
The symptoms (for an outer helgrind and inner none): a thread cannot be
created (see below). Investigating further, this is caused by malloc/...
not working. When run with outer helgrind + inner none, the malloc
calls returns 0x0. The inner also complaints it can't handle helgrind
client request (see below).
After investigation, I have concluded that the problem is that the inner
tool (none in this case) is interpreting the redirection special symbols
found in the vgpreload of the outer tool.
So, the none tool is "installing" redirection for e.g. malloc to
redirect to a function it does not have.
Extract of the trace of the problem (see func=0x0)
>--14266:2:transtab discard_translations(0x4e26d93, 1) req by redir_new_DebugInfo(to_addr)
>--14266:2:transtab FAST, ec = 77
>==14266== Adding active redirection:
>--14266-- new: 0x052c9750 (memcpy ) R-> (0000.0) 0x04e26d93 memcpy
>--14266-- REDIR: 0x52c08c0 (malloc) redirected to 0x4e25c68 (malloc)
>--14266-- VG_USERREQ__CLIENT_CALL1: func=0x0
loops/sleep_ms/burn/threads_spec: 100000 0 10000 B-B-B-B-
>--14266-- REDIR: 0x5034c30 (pthread_create@@GLIBC_2.2.5) redirected to 0x4e2ae52 (pthread_create@*)
>==14266== Warning:
>==14266== unhandled client request: 0x48470127 (HG+0x127). Perhaps
>==14266== VG_(needs).client_requests should be set?
>--14266-- REDIR: 0x52bfe50 (calloc) redirected to 0x4e24f2b (calloc)
>--14266-- VG_USERREQ__CLIENT_CALL2: func=0x0
>--14266-- REDIR: 0x5038660 (pthread_rwlock_rdlock) redirected to 0x4e280df (pthread_rwlock_rdlock)
>--14266-- REDIR: 0x52c9750 (memcpy) redirected to 0x4e26d93 (memcpy)
>--14266-- REDIR: 0x5038c70 (pthread_rwlock_unlock) redirected to 0x4e27c04 (pthread_rwlock_unlock)
>--14266-- VG_USERREQ__CLIENT_CALL1: func=0x0
Unexpected error.
--14266:1:gdbsrv signal 6 tid 1
--14266:1:gdbsrv not connected => pass
>--14266:1:gdbsrv signal 6 tid 1
>--14266:1:gdbsrv not connected => pass
>==14266==
>==14266== Process terminating with default action of signal 6 (SIGABRT)
>--14266:1:mallocfr newSuperblock at 0x3F4254000 (pszB 1048544) owner VALGRIND/exectxt
>==14266== at 0x527C165: raise (raise.c:64)
>==14266== by 0x527EF6F: abort (abort.c:92)
>==14266== by 0x52752B0: __assert_fail (assert.c:81)
>==14266== by 0x503537C: pthread_create@@GLIBC_2.2.5 (allocatestack.c:573)
>==14266== by 0x4E2AD46: pthread_create_WRK (hg_intercepts.c:255)
>==14266== by 0x4E2AE5A: pthread_create@* (hg_intercepts.c:286)
>==14266== by 0x400F3A: main (parallel_sleepers.c:161)
>--14266:1:syswrap- thread_wrapper(tid=1): exit
>--14266:1:syswrap- run_a_thread_NORETURN(tid=1): post-thread_wrapper
>--14266:1:syswrap- run_a_thread_NORETURN(tid=1): last one standing
I have somewhat bypassed the problem with the patch below,
which avoids the inner to execute the redirection of a vgpreload
of the outer.
It looks like an outer helgrind+inner cachegrind goes much
better (still running).
Outer helgrind + inner none goes further, but then the outer generates a SEGV
when computing a backtrace when the thread 1 is cloning a thread 2.
Any idea if the patch below is the way to go ?
Or if there is something which I have not understood/did wrong ?
Philippe
ndex: coregrind/m_redir.c
===================================================================
--- coregrind/m_redir.c (revision 12391)
+++ coregrind/m_redir.c (working copy)
@@ -49,6 +49,7 @@
#include "pub_core_xarray.h"
#include "pub_core_clientstate.h" // VG_(client___libc_freeres_wrapper)
#include "pub_core_demangle.h" // VG_(maybe_Z_demangle)
+#include "pub_core_libcproc.h" // VG_(libdir)
#include "config.h" /* GLIBC_2_* */
@@ -389,6 +390,7 @@
Bool isText;
const UChar* newdi_soname;
+
# if defined(VG_PLAT_USES_PPCTOC)
check_ppcTOCs = True;
# endif
@@ -397,6 +399,23 @@
newdi_soname = VG_(DebugInfo_get_soname)(newdi);
vg_assert(newdi_soname != NULL);
+#ifdef ENABLE_INNER
+ {
+ const UChar* newdi_filename;
+ VG_(message)(Vg_DebugMsg, "VALGRIND_LIB %s\n", VG_(libdir));
+ newdi_filename = VG_(DebugInfo_get_filename)(newdi);
+ VG_(message)(Vg_DebugMsg, "checking ignoring redir in %s %s\n", newdi_soname, newdi_filename);
+ /* avoid reading the redirections which are for the outer. */
+ if (VG_(strstr)(newdi_filename, "/vgpreload")) {
+ VG_(message)(Vg_DebugMsg, "contains /vgpreload\n");
+ if( !VG_(strstr)(newdi_filename, (Char*) VG_(libdir))) {
+ VG_(message)(Vg_DebugMsg, "not containing inner VG_(libdir) => ignoring redir in %s\n", newdi_filename);
+ return;
+ }
+ }
+ }
+#endif
+
/* stay sane: we don't already have this. */
for (ts = topSpecs; ts; ts = ts->next)
vg_assert(ts->seginfo != newdi);
|