https://bugs.kde.org/show_bug.cgi?id=342040

Nach <nac...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nac...@gmail.com

--- Comment #1 from Nach <nac...@gmail.com> ---
While testing my own implementation of posix_spawn()
(http://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn.html)
using the following snippet:

char stack[4096];
pid_t pid = clone(child, stack+sizeof(stack), CLONE_VM|CLONE_VFORK|SIGCHLD,
args);

I also noticed this being mishandled. Running valgrind (valgrind-3.12.0.SVN)
through strace, I see valgrind is running this code as:
clone(child_stack=0, flags=SIGCHLD)     = 4070

While dropping off some of the flags is annoying, and it really should NOT be
doing that, it's setting the child_stack to 0! This is a garaunteed
segmentation fault or other nasty behavior occuring. Notice the address in
above message  "Access not within mapped region at address 0xFFFFFFFFFFFFFFD4",
that's stack growing downwards on a 64-bit platform from 0. 0 only seems to be
allowed as a child_stack with very specific flags.

The popular musl (http://www.musl-libc.org/) C library's posix_spawn() is also
affected as it uses similar code internally
(http://git.musl-libc.org/cgit/musl/tree/src/process/posix_spawn.c?id=8f7bc690f07e90177b176b6e19736ad7c1d49840#n168).

Valgrind should honor the specified child_stack or instead replace with its own
managed stack instead of just setting it to 0 with these flags, which makes it
impossible to debug programs using these implementations of posix_spawn().

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to