|
From: Olly B. <ol...@su...> - 2003-08-13 16:51:33
|
> A12. One possible cause is that your program modifies its
> environment variables, possibly including zeroing them
> all. Valgrind relies on the LD_PRELOAD and LD_LIBRARY_PATH
> variables, so zeroing them will break things.
I'm not certain I understand the mechanisms involved completely, but
would it work for valgrind to wrapper getenv, setenv, and putenv and
keep track of what the app thinks LD_PRELOAD and LD_LIBRARY_PATH (and
indeed VG_ARGS) are set to, but when making syscalls, actually use the
values set with the paths valgrind needs prepended?
Or simpler, just wrapper setenv and putenv and force valgrind's paths
in and prevent VG_ARGS from being changed, but I worry slightly that an
app might assume it knows how long a variable is because it just set it
- something like this rather stupid contrived example:
int foo(const char * value) {
char * p = malloc(strlen(value) + 10);
if (!p) return -1;
setenv("LD_PRELOAD", value, 1);
bar();
strcpy(p, getenv("LD_PRELOAD));
strcat(p, ":/usr/lib");
setenv("LD_PRELOAD", p, 1);
baz();
free(p);
return 0;
}
Cheers,
Olly
|