This seems to be a valid issue:
- Valgrind empties out the variable immediately after LD_PRELOAD
- This happens when LD_PRELOAD is not set or is empty before starting
the program with valgrind.

Please try the attached testcase:
valgrind --trace-children=yes denv >& denv.log

The test binary forks and execs itself till it can add about 55
environment variables. It sets the environment variable before the
exec. Reduce or increase the number 55 based on the number of env vars
you already have in your environment. Add 5 to the number of existing
variables to arrive at this number.

After running, check the output log and watch the variable after
LD_PRELOAD. After the second cycle the variable is emptied out.

- The code is in coregrind/m_libcproc.c, function mash_colon_env
- mash_colon_env does a *varp++ twice when there is a match and
while(*varp) overshoots the \0
- confirmed on x86 and AMD64 bit systems with Valgrind 3.5.0.

Thanks,
Madhan.

On Thu, Nov 19, 2009 at 2:48 AM, Dan Kegel <[email protected]> wrote:
> On Wed, Nov 18, 2009 at 12:36 PM, Dan Kegel <[email protected]> wrote:
>> Using valgrind r10990 with --trace-children=yes, I noticed that sometimes
>> the environment variables in the client app were
>> not all there.  I managed to track it down a
>> bit - in coregrind/m_initimg/initimg-linux.c, on entry to
>> setup_client_env(), on about the fourth time through,
>> there was an empty environment variable (no name,
>> no =, no value) inserted after LD_PRELOAD=, i.e.
>>      "LD_PRELOAD="
>>      ""
>>      "XAUTHORITY=/home/dank/.Xauthority"
>>
>> Could the LD_PRELOAD munging in that file have
>> misbehaved somehow?
>
> I should mention: this probably wouldn't affect most client
> apps, but I was running Wine, which processes the environment
> as a list, and stops when it finds an empty variable.
> I have a local patch in Wine to skip those, and I'm back in
> business for now.
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Valgrind-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/valgrind-users
>

Attachment: denv.c
Description: Binary data

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to