From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11456 Path: news.gmane.org!.POSTED!not-for-mail From: u-uy74@aetey.se Newsgroups: gmane.linux.lib.musl.general Subject: Re: more fun with non-Linux Linux ABI Date: Mon, 12 Jun 2017 10:30:12 +0200 Message-ID: <20170612083012.GT30784@example.net> References: <20170611180158.GS30784@example.net> <20170611215020.GB1627@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1497256261 24073 195.159.176.226 (12 Jun 2017 08:31:01 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 12 Jun 2017 08:31:01 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-11469-gllmg-musl=m.gmane.org@lists.openwall.com Mon Jun 12 10:30:57 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1dKKkS-00062r-8R for gllmg-musl@m.gmane.org; Mon, 12 Jun 2017 10:30:56 +0200 Original-Received: (qmail 18193 invoked by uid 550); 12 Jun 2017 08:30:59 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 18175 invoked from network); 12 Jun 2017 08:30:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fripost.org; h= in-reply-to:content-disposition:content-type:content-type :mime-version:references:message-id:subject:subject:from:from :date:date; s=20140703; t=1497256247; x=1499070648; bh=mYckITCyy 9jWVbA5FCK3Ko82m6odH3lVgChFOziri1k=; b=0iDJOkxhzfITnmTVB93jMJuF1 46QIbNwWyjTMJTy3T7LLwMbcK4FHHdUYtuCrx+W5ssJAah/G3OjmtWtBRc+RG0BH YwGar0SbR3Db8XOU+nr8iwtN2NILe8EedNVbkAwkS4y0mWxi8bKY4nOYE6j+nIh8 h/C7CXuykIkTyILBNk= X-Virus-Scanned: Debian amavisd-new at fripost.org Content-Disposition: inline In-Reply-To: <20170611215020.GB1627@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:11456 Archived-At: On Sun, Jun 11, 2017 at 05:50:20PM -0400, Rich Felker wrote: > On Sun, Jun 11, 2017 at 08:01:58PM +0200, u-uy74@aetey.se wrote: > > FWIIW: when running under Linux ABI on FreeBSD > > in musl-linked programs the child processes segfault right after a > > vfork(), before doing anything else: > > My first guess is that this is a FreeBSD bug... I agree. > > Remarkably this apparently does not affect glibc-based builds > > (I have not tested right now but otherwise it would have been known). > > Wonder what makes the difference. > > Is it possible that FreeBSD's Linux syscall emulation uses the > userspace stack to store some state during syscalls? For example maybe I am not sufficiently familiar with the FreeBSD internals to tell this. The linux_fork() and linux_vfork() functions are about 30 lines each and the only difference is --- fork +++ vfork ... struct fork_req fr; ... bzero(&fr, sizeof(fr)); - fr.fr_flags = RFFDG | RFPROC | RFSTOPPED; + fr.fr_flags = RFFDG | RFPROC | RFMEM | RFPPWAIT | RFSTOPPED; fr.fr_procp = &p2; if ((error = fork1(td, &fr)) != 0) return (error); ... I guess the musl vs glibc difference can happen if the latter implements vfork() in terms of clone() (?) linux_clone() has a much larger implementation in FreeBSD than linux_vfork() which could explain why the one works and the other does not. > > Otherwise a simple workaround would be an option to make vfork() > > a fork() synonym while building musl. (I do the this at applications > > build time instead, which helps.) > > > > Such an option would most probably result in a pretty small performance > > impact on modern (native) Linux. > > It's actually a pretty large impact; recent (4.x+ IIRC) versions of > GNU makes are considerably slower because they dropped use of vfork > and switched to fork rather than making it use posix_spawn like it > should. Thanks, good to know. Then I have to live with this impact on Linux or convince the FreeBSD team to fix linux_vfork(). Rune