From owner-freebsd-hackers@FreeBSD.ORG Tue Aug 14 08:18:45 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4BFC0106564A; Tue, 14 Aug 2012 08:18:45 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id B8B3C8FC08; Tue, 14 Aug 2012 08:18:44 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q7E8IgJ7000532; Tue, 14 Aug 2012 11:18:42 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q7E8IU26014215; Tue, 14 Aug 2012 11:18:30 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q7E8IUun014214; Tue, 14 Aug 2012 11:18:30 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 14 Aug 2012 11:18:30 +0300 From: Konstantin Belousov To: David Xu Message-ID: <20120814081830.GA5883@deviant.kiev.zoral.com.ua> References: <20120730102408.GA19983@stack.nl> <20120730105303.GU2676@deviant.kiev.zoral.com.ua> <20120805215432.GA28704@stack.nl> <20120806082535.GI2676@deviant.kiev.zoral.com.ua> <20120809105648.GA79814@stack.nl> <5029D727.2090105@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="yrj/dFKFPuw6o+aM" Content-Disposition: inline In-Reply-To: <5029D727.2090105@freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-hackers@freebsd.org, Jilles Tjoelker Subject: Re: system() using vfork() or posix_spawn() and libthr X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Aug 2012 08:18:45 -0000 --yrj/dFKFPuw6o+aM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 ? --yrj/dFKFPuw6o+aM Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAlAqCdUACgkQC3+MBN1Mb4hL3gCdFjUzOQrAjCo5i3Fk8SWi6ikS NE0AoJRfTnfkfAf2Rl8IJM2kGXtw6WVB =0wd3 -----END PGP SIGNATURE----- --yrj/dFKFPuw6o+aM--