|
From: Crispin F. <val...@fl...> - 2003-05-29 09:44:20
|
Hi,
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);
}
Cheers
Crispin
|
|
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
|
|
From: Crispin F. <val...@fl...> - 2003-05-29 11:08:28
|
Hi, > 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... As far as I can tell from that function it is just trying to remove its entries from the environment. It would probably make more sense for it to try and remove anything that is still around, and not complain if the application has removed the variables. If I get a chance I will have a look at getting it to remove anything that is still in the env that is valgrind related. > 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; Thanks, this fixes the running of CGI scripts under our Web Server (Zeus). Crispin |