From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#54458: 27.2; erc-dcc-get: Re-entering top level after C stack overflow Date: Tue, 29 Mar 2022 17:49:05 +0200 Message-ID: <4DA2DB05-D902-42DF-860D-87617FBB74C8@acm.org> References: <78459EAB-314B-4122-8E3B-7F82685D0DBA@acm.org> <83a6da9vm8.fsf@gnu.org> <87r16m46uf.fsf@neverwas.me> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_9AA5C53A-3A03-405E-9AED-89E4CE343F0E" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14963"; mail-complaints-to="usenet@ciao.gmane.io" Cc: fernandodemorais.jf@gmail.com, bandali@gnu.org, 54458@debbugs.gnu.org To: "J.P." Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 29 17:50:52 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nZE7Q-0003Nm-BA for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 29 Mar 2022 17:50:52 +0200 Original-Received: from localhost ([::1]:52814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZE7P-0004cb-5F for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 29 Mar 2022 11:50:51 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:58664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZE6d-0004an-1A for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2022 11:50:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39535) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nZE6c-0003kn-Nw for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2022 11:50:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nZE6c-0007e4-Ki for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2022 11:50:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 29 Mar 2022 15:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54458 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 54458-submit@debbugs.gnu.org id=B54458.164856895429327 (code B ref 54458); Tue, 29 Mar 2022 15:50:02 +0000 Original-Received: (at 54458) by debbugs.gnu.org; 29 Mar 2022 15:49:14 +0000 Original-Received: from localhost ([127.0.0.1]:33432 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nZE5p-0007cx-Ly for submit@debbugs.gnu.org; Tue, 29 Mar 2022 11:49:13 -0400 Original-Received: from mail70c50.megamailservers.eu ([91.136.10.80]:54692) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nZE5n-0007cm-FF for 54458@debbugs.gnu.org; Tue, 29 Mar 2022 11:49:12 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1648568948; bh=WNauldWf7zcvnaHvcSJ4a0WgWlz9llZpmnltyFkucb8=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=EgsY490nNu0FYWH7dm2gKMEzbCFSJHVv8ltHovKU+3Ybg0MoW1CN3PbkvqwsrvPzN VL5csp/ZvYsJ4RdY9QJaD2kj4kRLxeU1KOPsJLl/g+AZhNM4bD6Y3AHV/0aOxcfOSO fOrcUUyvG4A7H8Ne9wlsRmKs278vMS+Py6NXv3SU= Feedback-ID: mattiase@acm.or Original-Received: from smtpclient.apple (c188-150-171-71.bredband.tele2.se [188.150.171.71]) (authenticated bits=0) by mail70c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 22TFn5gV013251; Tue, 29 Mar 2022 15:49:07 +0000 In-Reply-To: <87r16m46uf.fsf@neverwas.me> X-Mailer: Apple Mail (2.3654.120.0.1.13) X-CTCH-RefID: str=0001.0A742F25.62432A74.0070, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-Origin-Country: SE X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:229066 Archived-At: --Apple-Mail=_9AA5C53A-3A03-405E-9AED-89E4CE343F0E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 28 mars 2022 kl. 14.08 skrev J.P. : > As you highlighted up thread, inhibited sends appeal to > `wait_reading_process_output' to try and shake something loose. I = agree > such occasions seem likeliest to trigger "unexpected" filter nesting. Although it seems reasonable to require that filter functions abstain = from sending more data to the process, there may be another way: = preventing re-entering process-send calls from recursing further. Attached is a proof of concept: if process-send calls are invoked when = another activation already exists, just enqueue the data and let the = previous activation deal with the actual transmission. That nips the = recursion in the buds. The principle seems sound but if anyone can think of problems with the = approach, please do tell. Of course, one reason to make the change in ERC is that it would fix the = problem in all Emacs versions, not just 29. --Apple-Mail=_9AA5C53A-3A03-405E-9AED-89E4CE343F0E Content-Disposition: attachment; filename=send-process-nesting.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="send-process-nesting.diff" Content-Transfer-Encoding: 7bit diff --git a/src/process.c b/src/process.c index 993e1c5603..694307b43a 100644 --- a/src/process.c +++ b/src/process.c @@ -6393,6 +6393,14 @@ write_queue_pop (struct Lisp_Process *p, Lisp_Object *obj, return 1; } +static int send_process_nesting = 0; + +static void +unwind_send_process (void) +{ + send_process_nesting--; +} + /* Send some data to process PROC. BUF is the beginning of the data; LEN is the number of characters. OBJECT is the Lisp object that the data comes from. If OBJECT is @@ -6510,6 +6518,18 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len, buf = SSDATA (object); } + if (send_process_nesting > 0) + { + /* We are already inside a send_process activation higher up the + call chain; let that take care of writing the queued data. */ + write_queue_push (p, object, buf, len, 0); + return; + } + + specpdl_ref count = SPECPDL_INDEX (); + record_unwind_protect_void (unwind_send_process); + send_process_nesting++; + /* If there is already data in the write_queue, put the new data in the back of queue. Otherwise, ignore it. */ if (!NILP (p->write_queue)) @@ -6633,6 +6653,7 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len, } } while (!NILP (p->write_queue)); + unbind_to (count, Qnil); } DEFUN ("process-send-region", Fprocess_send_region, Sprocess_send_region, --Apple-Mail=_9AA5C53A-3A03-405E-9AED-89E4CE343F0E Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail=_9AA5C53A-3A03-405E-9AED-89E4CE343F0E--