From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.bugs Subject: bug#8705: 23.3; Emacs occasionally crashes (segfault) just after starting it Date: Thu, 09 Oct 2014 16:03:13 -0400 Message-ID: References: <87sjs9ycor.fsf@ypig.lip.ens-lyon.fr> <20140922130621.GD3600@ypig.lip.ens-lyon.fr> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1412885078 19084 80.91.229.3 (9 Oct 2014 20:04:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 9 Oct 2014 20:04:38 +0000 (UTC) Cc: Vincent Lefevre , 8705@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 09 22:04:29 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XcJwY-0005eM-Bj for geb-bug-gnu-emacs@m.gmane.org; Thu, 09 Oct 2014 22:04:10 +0200 Original-Received: from localhost ([::1]:44890 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcJwX-0007a1-Lb for geb-bug-gnu-emacs@m.gmane.org; Thu, 09 Oct 2014 16:04:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcJwR-0007Zt-5C for bug-gnu-emacs@gnu.org; Thu, 09 Oct 2014 16:04:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XcJwQ-00054c-4p for bug-gnu-emacs@gnu.org; Thu, 09 Oct 2014 16:04:03 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47934) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcJwQ-00054X-20 for bug-gnu-emacs@gnu.org; Thu, 09 Oct 2014 16:04:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XcJwP-0004Jy-Ks for bug-gnu-emacs@gnu.org; Thu, 09 Oct 2014 16:04:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Glenn Morris Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 09 Oct 2014 20:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8705 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 8705-submit@debbugs.gnu.org id=B8705.141288499816541 (code B ref 8705); Thu, 09 Oct 2014 20:04:01 +0000 Original-Received: (at 8705) by debbugs.gnu.org; 9 Oct 2014 20:03:18 +0000 Original-Received: from localhost ([127.0.0.1]:39498 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XcJvh-0004Ig-Jm for submit@debbugs.gnu.org; Thu, 09 Oct 2014 16:03:17 -0400 Original-Received: from fencepost.gnu.org ([208.118.235.10]:47885) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XcJvf-0004IY-7P for 8705@debbugs.gnu.org; Thu, 09 Oct 2014 16:03:15 -0400 Original-Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1XcJvd-0007EB-Vm; Thu, 09 Oct 2014 16:03:14 -0400 X-Spook: virus Axis of Evil encryption Glock Osama CISU X-Ran: _Vg9QZq!!mlWHU<34Q=4g9/aaNO-x^.1[?MhAn<^!L5H;Cxk6N^w8P7Q=gW_8=Vf5OKr/8 X-Hue: white X-Attribution: GM In-Reply-To: (Stefan Monnier's message of "Sat, 27 Sep 2014 00:10:18 -0400") User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:94350 Stefan Monnier wrote: >> Any news on this bug? Debian's GNU Emacs 24.3.1 is still affected. > > Same question here. Comments from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=699325#17: > What emacs appears to be doing is: > > * vfork() in thread A > - parent: thread A suspended > - parent: threads B, C, ... (one of which is the Gtk GUI) continue > - child: "shares all memory with its parent, including the stack" > per vfork(2) > > * child copies environ and modifies the copy as needed > > RACE: > child + parent thread A: > * changes the global environ pointer, potentially making it point to > a new mmap() that only exists in the child process (or something?) > * child: calls execvp() > * parent: thread A resumes and puts the old environ back > parent threads B, C... > * threads B, C, ... continue their work and might call getenv() > > If the child wins the race, everything's OK; if the parent's threads B, > C... "win" the race, everything explodes. It seems that Gtk, in the > parent's GUI thread, is now more likely to "win" the race and crash, > because new features like touchscreen support have the side-effect that > it calls getenv() more often. > > On the upstream emacs bug, Troels Nielsen wrote: > > In the meantime, retaining support for vfork would be nice, because > > on some platforms, like Cygwin, fork is still very slow > > but on Linux (and hopefully also *BSD and Hurd), fork() is quite fast, > and considerably less crashy. I would suggest changing the vfork() call > to fork(), making sure the environ rewriting is only done in the child > side of the fork(), and seeing whether that helps. > > Alternatively, emacs could use execvpe() instead of execve() on > platforms where it exists (including all GNU platforms as far as I > know), so that it does not need to alter the value of environ at all on > such platforms. I think that would fix this?