Fix problem with trace-children=yes when using a tool which replaces
malloc.  The problem was that LD_PRELOAD was being left set with
our replacement .so files, which meant they were being applied to
stage1/stage2.  This caused malloc to fail and a subsequent SIGSEGV.
This change unconditionally removes all of Valgrind's special environment
before each execve, since it will be replaced as needed by the child
Valgrind.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2184 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/vg_syscalls.c b/coregrind/vg_syscalls.c
index 7689012..a5dcc94 100644
--- a/coregrind/vg_syscalls.c
+++ b/coregrind/vg_syscalls.c
@@ -1767,9 +1767,11 @@
       its own new thread.) */
    VG_(nuke_all_threads_except)( VG_INVALID_THREADID );
 
-   if (!VG_(clo_trace_children)) {
+   {
       /* Make the LD_LIBRARY_PATH/LD_PRELOAD disappear so that the
-	 child doesn't get our libpthread and other stuff */
+	 child doesn't get our libpthread and other stuff.  This is
+	 done unconditionally, since if we are tracing the child,
+	 stage1/2 will set up the appropriate client environment. */
       Int i;
       Char** envp = (Char**)arg3;
       Char*  ld_preload_str = NULL;
@@ -1800,7 +1802,9 @@
 
 	 /* XXX if variable becomes empty, remove it completely? */
       }
-   } else {
+   }
+
+   if (VG_(clo_trace_children)) {
       /* If we're tracing the children, then we need to start it
 	 with our starter+arguments.
       */