From: Nicholas N. <nj...@ca...> - 2003-05-29 10:20:53
|
On 29 May 2003, Crispin Flowerday wrote: > The following program is simple test program that cause valgrind (cvs > version) to crash out with the mash_LD_PRELOAD... error when it > encounters the exec. (the FAQ asked for a test case). > > #include <stdlib.h> > #include <stdio.h> > #include <unistd.h> > > int main( int argc, char ** argv ) > { > char * arg[] = { "/bin/true", 0 }; > char * env[] = { "PATH=/bin", 0 }; > > execve( "/bin/true", arg, env ); > > fprintf( stderr, "Failed to exec\n" ); > exit(1); > } The FAQ says: One possible cause is that your program modifies its environment variables, possibly including zeroing them all. Avoid this if you can. Well, you haven't zeroed all your environment variables, but you have zeroed LD_PRELOAD and LD_LIBRARY_PATH, which Valgrind currently requires to be non-zeroed. Maybe if either of them are zeroed it should just skip the mash_ stuff... If this is causing problems for you (ie. you're not just playing let's-try-to-confuse-Valgrind :) change the first line of code in coregrind/vg_main.c:VG_(mash_LD_PRELOAD_and_LD_LIBRARY_PATH)() from this: if (ld_preload_str == NULL || ld_library_path_str == NULL) MUTANCY(0); to this: if (ld_preload_str == NULL || ld_library_path_str == NULL) return; It works for the program above, at least. N |