From: Philippe Waroquiers Date: Thu, 14 Jun 2012 22:18:50 +0000 (+0000) Subject: Have the inner Valgrind registering the interim_stack asap. X-Git-Tag: svn/VALGRIND_3_8_0~230 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40ecbb08e664ab599f2d9864eca306e3b82bea29;p=thirdparty%2Fvalgrind.git Have the inner Valgrind registering the interim_stack asap. This is needed to have the outer valgrind able to do stack traces of the inner Valgrind before the main thread runs. Without this, the outer crashes (segv) when doing a stack trace. In mtV.txt, an ugly kludge was described to avoid this crash. This is the clean solution replacing the kludge. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12638 --- diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 7a35112eca..d02e5a4b36 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -65,6 +65,10 @@ #include "pub_core_translate.h" // For VG_(translate) #include "pub_core_trampoline.h" #include "pub_core_transtab.h" +#include "pub_tool_inner.h" +#if defined(ENABLE_INNER_CLIENT_REQUEST) +#include "valgrind.h" +#endif /*====================================================================*/ @@ -1457,6 +1461,19 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp ) struct vki_rlimit zero = { 0, 0 }; XArray* addr2dihandle = NULL; + // For an inner Valgrind, register the interim stack asap. + // This is needed to allow the outer valgrind to do stacktraces during init. + // Note that this stack is not unregistered when the main thread + // is switching to the (real) stack. Unregistering this would imply + // to save the stack id in a global variable, and have a "if" + // in run_a_thread_NORETURN to do the unregistration only for the + // main thread. This unregistration is not worth this complexity. + INNER_REQUEST + ((void) VALGRIND_STACK_REGISTER + (&VG_(interim_stack).bytes[0], + &VG_(interim_stack).bytes[0] + sizeof(VG_(interim_stack)))); + + //============================================================ // // Nb: startup is complex. Prerequisites are shown at every step.