Bug 92763 - fork/exec and putenv invoked from pthread report invalid reads
Summary: fork/exec and putenv invoked from pthread report invalid reads
Status: RESOLVED DUPLICATE of bug 85625
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-05 21:41 UTC by Richard Dykiel
Modified: 2004-11-06 01:15 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
bug demonstration code (10.00 KB, application/octet-stream)
2004-11-05 21:43 UTC, Richard Dykiel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Dykiel 2004-11-05 21:41:43 UTC
The context is a daemon started from inittab; this daemon spawns pthreads. A
pthread can invoke putenv(), fork(), execve().

Valgrind reports invalid reads on the first environment variable
(__environ[0]="PWD=/"); examples provided below. 

I wrote a very simple program which demonstrates that, when fork/exec is invoked
outside pthreads, valgrind does not report errors. When invoked from within
pthreads, it reports the errors.I'll try to attach the tarfile of the sources.

Linux Debian ...
# uname -a
Linux 2.4.26-acopia15 #1 SMP Fri Oct 22 21:58:40 EDT 2004 i686 unknown

# valgrind --version
valgrind-2.2.0

Examples invalid reads:

==753== Thread 3:
==753== Invalid read of size 1
==753==    at 0x1B8FF8F4: strncmp (mac_replace_strmem.c:233)
==753==    by 0x1BB996D4: __add_to_environ (../sysdeps/generic/setenv.c:131)
==753==    by 0x1BB9962C: putenv (../sysdeps/generic/putenv.c:67)
==753==    by 0x8056F9B: ??? (system.c:56)
==753==    by 0x8054F95: ??? (svc_agent_processor.c:188)
==753==    by 0x8055AC4: ??? (svc_agent_processor.c:832)
==753==    by 0x8055FCC: ??? (svc_agent_processor.c:1069)
==753==    by 0x8056959: ??? (svc_agent_processor.c:1628)
==753==    by 0x1B9AE999: thread_wrapper (vg_libpthread.c:867)
==753==    by 0xB000F0BF: (within /usr/lib/valgrind/stage2)
==753==  Address 0x52BFEEB6 is not stack'd, malloc'd or (recently) free'd
==753== 
==753== Thread 3:
==753== Syscall param execve(envp[i]) contains uninitialised or unaddressable
byte(s)
==753==    at 0x1BC0EF06: execve (../sysdeps/unix/sysv/linux/execve.c:70)
==753==    by 0x8056FF5: ??? (system.c:71)
==753==    by 0x8054F95: ??? (svc_agent_processor.c:188)
==753==    by 0x8055AC4: ??? (svc_agent_processor.c:832)
==753==    by 0x8055FCC: ??? (svc_agent_processor.c:1069)
==753==    by 0x8056959: ??? (svc_agent_processor.c:1628)
==753==    by 0x1B9AE999: thread_wrapper (vg_libpthread.c:867)
==753==    by 0xB000F0BF: (within /usr/lib/valgrind/stage2)
==753==  Address 0x52BFEEB6 is not stack'd, malloc'd or (recently) free'd
Comment 1 Richard Dykiel 2004-11-05 21:43:23 UTC
Created attachment 8182 [details]
bug demonstration code

Attaching example code. Thanks.
Comment 2 Tom Hughes 2004-11-06 01:15:15 UTC
There is some sort of problem with the way the environment is handled on fork/exec but I've never been able to work out what is causing it. There's already a bug for it anyway so I'm going to join this to it - your new information about it only happening with pthreads is certainly interesting.

*** This bug has been marked as a duplicate of 85625 ***