|
From: Santeri P. <sa...@ss...> - 2003-08-15 07:25:37
|
Crispin Flowerday wrote:
>Monitoring the environ variable is not perfect either as you can quite
>happily call execve directly and pass a brand new environment in. This
>is presumably all the valgrind sees at the moment (AIUI all the other
>exec functions are libc wrappers).
>
>Wouldn't it be possible for valgrind to realise that the required
>environment variables aren't present and add them in again, either by
>mallocing some space for the new env array and the env entries, or by
>using a few static buffers ?
>
>
Good point. I noticed that Valgrind does the following steps wrt/ exec:
1. valgrind.so is hooked using LD_PRELOAD
2. Command line arguments are passed to coregrind through the VG_ARGS
environmental variable.
3. When an execve is trapped (vg_syscalls.c), clo_trace_children is
checked: if child tracing is enabled, valgrind does nothing. If child
tracing is disabled, mash_LD_PRELOAD_and_LD_LIBRARY_PATH is called to
modify LD_PRELOAD and LD_LIBRARY_PATH to remove valgrind.
To allow tracing environmetal variables, I think valgrind should instead
always remove itself from LD_PRELOAD, LD_LIBRARY_PATH and clear VG_ARGS
from the environment. When it traps the execve system call, it would
look into clo_trace_children, and if child tracing is enabled,
LD_PRELOAD, LD_LIBRARY_PATH and VG_ARGS would be modified to include the
original values (since valgrind knows what the values are, this step
would just copy the known correct values in).
--
sa...@ss... I have no opinions, since I cannot express any, after all.
If you think you saw an opinion, contact your optometrist.
|