This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug nptl/10311] clone(CLONE_VM) fails with pthread_getattr_np on i386
- From: "bugdal at aerifal dot cx" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: Thu, 27 Sep 2012 18:15:42 +0000
- Subject: [Bug nptl/10311] clone(CLONE_VM) fails with pthread_getattr_np on i386
- Auto-submitted: auto-generated
- References: <bug-10311-131@http.sourceware.org/bugzilla/>
http://sourceware.org/bugzilla/show_bug.cgi?id=10311
Rich Felker <bugdal at aerifal dot cx> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bugdal at aerifal dot cx
--- Comment #6 from Rich Felker <bugdal at aerifal dot cx> 2012-09-27 18:15:42 UTC ---
The code is not correct. Basically, there's nothing you can safely do with
CLONE_VM unless the child restricts itself to pure computation and direct
syscalls (via sys/syscall.h). If you use any of the standard library, you risk
the parent and child clobbering each other's internal states. You also have
issues like the fact that glibc caches the pid/tid in userspace, and the fact
that glibc expects to always have a valid thread pointer which your call to
clone is unable to initialize correctly because it does not know (and should
not know) the internal implementation of threads.
I know my warning not to call even async-signal-safe functions in libc, and to
make all syscalls manually, seems extreme, but I don't see any way around it
given the above issues. Perhaps glibc could document a set of "clone_vm-safe"
functions that can be used in the child after cloning with CLONE_VM without
having to worry that they will access internal libc state or need a valid
thread pointer.
However, I think it's probably better to just refrain from abusing clone and
use pthread_create the way it was intended to be used, possibly with unshare()
afterwards if you want some threads to have their own signal/fd/etc.
namespaces.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.