This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug nptl/10311] clone(CLONE_VM) fails with pthread_getattr_np on i386


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]