From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#12446: port better to POSIX hosts lacking _setjmp Date: Sat, 15 Sep 2012 00:50:17 -0700 Organization: UCLA Computer Science Department Message-ID: <50543339.3090500@cs.ucla.edu> References: <50538925.3010608@cs.ucla.edu> <83txv0tkho.fsf@gnu.org> <5053A177.1020608@cs.ucla.edu> <83sjaju5ca.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1347695471 9492 80.91.229.3 (15 Sep 2012 07:51:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 15 Sep 2012 07:51:11 +0000 (UTC) Cc: lekktu@gmail.com, 12446@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Sep 15 09:51:14 2012 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 1TCn9h-00078B-7u for geb-bug-gnu-emacs@m.gmane.org; Sat, 15 Sep 2012 09:51:09 +0200 Original-Received: from localhost ([::1]:38748 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCn9d-0004jv-77 for geb-bug-gnu-emacs@m.gmane.org; Sat, 15 Sep 2012 03:51:05 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCn9a-0004jq-EJ for bug-gnu-emacs@gnu.org; Sat, 15 Sep 2012 03:51:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TCn9Z-0004Tu-4j for bug-gnu-emacs@gnu.org; Sat, 15 Sep 2012 03:51:02 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:53393) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCn9Z-0004Tq-1G for bug-gnu-emacs@gnu.org; Sat, 15 Sep 2012 03:51:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TCnAY-0004oG-BG for bug-gnu-emacs@gnu.org; Sat, 15 Sep 2012 03:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 15 Sep 2012 07:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12446 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 12446-submit@debbugs.gnu.org id=B12446.134769548218435 (code B ref 12446); Sat, 15 Sep 2012 07:52:02 +0000 Original-Received: (at 12446) by debbugs.gnu.org; 15 Sep 2012 07:51:22 +0000 Original-Received: from localhost ([127.0.0.1]:34706 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TCn9t-0004nI-R2 for submit@debbugs.gnu.org; Sat, 15 Sep 2012 03:51:22 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:58630) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TCn9q-0004nA-Nj for 12446@debbugs.gnu.org; Sat, 15 Sep 2012 03:51:20 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 73E0D39E800D; Sat, 15 Sep 2012 00:50:16 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id H4SZYgLV52c8; Sat, 15 Sep 2012 00:50:16 -0700 (PDT) Original-Received: from [192.168.1.3] (pool-108-23-119-2.lsanca.fios.verizon.net [108.23.119.2]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id F010539E8008; Sat, 15 Sep 2012 00:50:15 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 In-Reply-To: <83sjaju5ca.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:64336 Archived-At: On 09/15/2012 12:12 AM, Eli Zaretskii wrote: > On which platforms does longjmp change the signal > mask and how, and in what ways can this "mess things up and slow > things down"? For example, under FreeBSD, setjmp saves the signal mask, and longjmp restores the signal mask to the value that it had when setjmp was called. See . FreeBSD is not alone in this -- it's sort of a BSD tradition -- but I don't have a list handy of exactly which OSes do it and which do not. Saving and restoring the signal mask takes time -- often system calls are involved. Emacs doesn't need the mask saved and restored, typically, so the effort is wasted. It's not uncommon for _setjmp+_longjmp to be 30x faster than setjmp+longjmp. This is partly why Emacs has long preferred _setjmp if available. Messups are trickier, because they involve rare race conditions. They can occur if Emacs or a system call has set the signal mask to X, but a longjump unexpectedly changes it to Y, where Y is not equal to X. This can happen if a signal handler invokes longjmp, either directly or indirectly. For example, Emacs signal handlers can invoke xmalloc, which can do a longjmp if memory is full, leading to a rare bug. Arguably signal handlers should not invoke malloc -- and I'll submit a patch shortly along those lines -- but regardless, it's better if Emacs's nonlocal gotos uniformly leave the signal mask alone, rather than leaving it alone on some hosts and messing with it on others.