system() using vfork() or posix_spawn() and libthr

Konstantin Belousov kostikbel at gmail.com
Tue Aug 14 08:18:45 UTC 2012


On Tue, Aug 14, 2012 at 12:42:15PM +0800, David Xu wrote:
> I simply duplicated idea from OpenSolaris, here is my patch
> which has similar feature as your patch, and it also tries to
> prevent vforked child from corrupting parent's data:
> http://people.freebsd.org/~davidxu/patch/libthr-vfork.diff
You shall not return from vfork() frame in the child. Otherwise, the
same frame is appears to be destroyed in parent, and parent dies. More
often on !x86, but right combination of events on x86 is deadly too.
If pid or curthread local variables are spilled into stack save area,
then child will override them, and e.g. parent could see pid == 0,
returning it to caller.

This was the reason why I went to asm wrapper for vfork.

Also, it seems that in mt process, malloc and rtld are still broken,
or am I missing something ?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20120814/5bf87854/attachment.pgp


More information about the freebsd-hackers mailing list