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#18410: Use SAFE_ALLOCA etc. to avoid unbounded stack allocation. Date: Fri, 05 Sep 2014 08:01:31 -0700 Organization: UCLA Computer Science Department Message-ID: <5409D04B.90009@cs.ucla.edu> References: <5409536B.5090201@cs.ucla.edu> <54097827.1020508@yandex.ru> 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 1409929353 30329 80.91.229.3 (5 Sep 2014 15:02:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 5 Sep 2014 15:02:33 +0000 (UTC) Cc: 18410@debbugs.gnu.org To: Dmitry Antipov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Sep 05 17:02:26 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 1XPv1s-0005UO-GQ for geb-bug-gnu-emacs@m.gmane.org; Fri, 05 Sep 2014 17:02:24 +0200 Original-Received: from localhost ([::1]:58284 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPv1p-0003kz-Pl for geb-bug-gnu-emacs@m.gmane.org; Fri, 05 Sep 2014 11:02:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPv1e-0003io-T3 for bug-gnu-emacs@gnu.org; Fri, 05 Sep 2014 11:02:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XPv1X-0005vK-CC for bug-gnu-emacs@gnu.org; Fri, 05 Sep 2014 11:02:10 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:40165) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPv1X-0005vA-7n for bug-gnu-emacs@gnu.org; Fri, 05 Sep 2014 11:02:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XPv1W-00089k-IS for bug-gnu-emacs@gnu.org; Fri, 05 Sep 2014 11:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 05 Sep 2014 15:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18410 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 18410-submit@debbugs.gnu.org id=B18410.140992931131333 (code B ref 18410); Fri, 05 Sep 2014 15:02:02 +0000 Original-Received: (at 18410) by debbugs.gnu.org; 5 Sep 2014 15:01:51 +0000 Original-Received: from localhost ([127.0.0.1]:59962 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XPv1K-00089I-Mz for submit@debbugs.gnu.org; Fri, 05 Sep 2014 11:01:51 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:47288) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XPv1G-000891-Mk for 18410@debbugs.gnu.org; Fri, 05 Sep 2014 11:01:47 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id AB5BDA60020; Fri, 5 Sep 2014 08:01:40 -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 r8A+MvGie2MJ; Fri, 5 Sep 2014 08:01:32 -0700 (PDT) Original-Received: from [192.168.1.9] (pool-71-177-17-123.lsanca.dsl-w.verizon.net [71.177.17.123]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id EB2C8A60003; Fri, 5 Sep 2014 08:01:31 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 In-Reply-To: <54097827.1020508@yandex.ru> 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:93065 Archived-At: Dmitry Antipov wrote: > USE_SAFE_ALLOCA; |- > ptrdiff_t count = SPECPDL_INDEX (); |- | > ... | inner bind | > outer bind > Lisp_Object result = unbind_to (count, Fsome_func ()); |- | > SAFE_FREE (); |- > return result; > > looks suboptimal because it calls unbind_to twice. I noticed that too, and actually coded up something along those lines, but decided to discard it as it added complexity and the patch was already pretty large. There is some virtue in having a simpler API, even if it's a tad suboptimal. Perhaps we can think of a way of combining SAFE_FREE and unbind_to so that there aren't two different ways in the source code of doing the same thing. To be honest I've never been a fan of 'RETURN_UNGCPRO (expr);', and would rather not encourage other macros along those lines. I was hoping that we could get rid of all the GCPRO stuff, and simplify the code under the assumption that GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS. I do like the idea about specbind returning the previous SPECPDL_INDEX, as that would simplify the code.