From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: Dynamic modules: MODULE_HANDLE_SIGNALS etc. Date: Mon, 21 Dec 2015 10:15:02 -0800 Organization: UCLA Computer Science Department Message-ID: <567841A6.4090408@cs.ucla.edu> References: <83mvu1x6t3.fsf@gnu.org> <565779CD.80405@cs.ucla.edu> <83io4nuc68.fsf@gnu.org> <83r3iht93x.fsf@gnu.org> <838u4psznr.fsf@gnu.org> <56772054.8010401@cs.ucla.edu> <83zix4scgf.fsf@gnu.org> <5677DBC9.6030307@cs.ucla.edu> <83io3rst2r.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1450721738 30610 80.91.229.3 (21 Dec 2015 18:15:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Dec 2015 18:15:38 +0000 (UTC) Cc: aurelien.aptel+emacs@gmail.com, p.stephani2@gmail.com, dancol@dancol.org, tzz@lifelogs.com, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 21 19:15:29 2015 Return-path: Envelope-to: ged-emacs-devel@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 1aB4zY-0000q0-NT for ged-emacs-devel@m.gmane.org; Mon, 21 Dec 2015 19:15:28 +0100 Original-Received: from localhost ([::1]:46733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aB4zY-0000ZN-4c for ged-emacs-devel@m.gmane.org; Mon, 21 Dec 2015 13:15:28 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43672) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aB4zF-0000Wk-R4 for emacs-devel@gnu.org; Mon, 21 Dec 2015 13:15:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aB4zE-0007tM-JQ for emacs-devel@gnu.org; Mon, 21 Dec 2015 13:15:09 -0500 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:39941) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aB4zA-0007ov-NZ; Mon, 21 Dec 2015 13:15:04 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id ED91A16066A; Mon, 21 Dec 2015 10:15:03 -0800 (PST) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id gtTUFFgw83oj; Mon, 21 Dec 2015 10:15:03 -0800 (PST) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 13C3A160D1A; Mon, 21 Dec 2015 10:15:03 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Y3p482mS-UOs; Mon, 21 Dec 2015 10:15:02 -0800 (PST) Original-Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id D914716066A; Mon, 21 Dec 2015 10:15:02 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 In-Reply-To: <83io3rst2r.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:196620 Archived-At: Eli Zaretskii wrote: > Are you > now saying something different from what you said back then, i.e. that > we cannot rely on any function/macro from lisp.h to be signal-safe? Yes and no. As I understood it, that old conversation was about functions that explicitly signal or throw, and it's safe to assume that EQ, NILP, etc. won't do that. The new conversation is about running out of memory, which is a different form of non-local exit. There may be other forms, such as operating-system signals (I don't recall exactly). > If so, we should add the necessary protection, in the form of calls to > MODULE_FUNCTION_BEGIN, to emacs-module.c functions that until now > relied on those lisp.h functions/macros to be safe. This wouldn't suffice for these other non-local exits, I think; at least, not as currently constructed. > AFAIK, proper C++ exception handling > requires non-trivial amounts of stack space that is not available when > there's stack overflow, where you have at most a single guard page to > work with. There should be workarounds for that. Surely the C++ community has run into this problem and has solutions. If we want to support C++ modules, we need to employ them. > I think there is some misunderstanding here, or some confusion, > perhaps mine: emacs-module.c is not supposed to deal with any C++ > exceptions. C++ exceptions are supposed to be caught at the C++ > level, below emacs-module.c, and handled there. An exception that > isn't caught will be recorded and will cause all the subsequent calls > to Lisp or to emacs-module.c function to fail, Why bother? If C++ exceptions are supposed to be caught by the C++ module in question, why does Emacs need to worry about C++ exceptions that are not caught? > What emacs-module.c does with non-local exits of _any_ kind is record > the first occurrence of such an exit, and silently return to the > caller, thus allowing the C++ objects on the stack to be destroyed > normally. IOW, it defers the exit until internal--module-call is > about to return. What problems do you see with that which cause you > to think it's error-prone, let alone dysfunctional? It uses a different model at the C level from what one sees in Elisp, or from what one normally sees in C for that matter. I don't feel that I will really understand the model unless I see some actual modules that do function calls and exception handling; but it's hard to believe that a model that does silent returns and that defers returns until later and that records some returns but not others will be problem-free. Wouldn't it be simpler to have a module invoke analogs of 'condition-case' and/or 'catch', and to dispense with the funcall_exit stuff?