From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#71223: 30.0.50; stack overflow after very fast opening and closing of frames Date: Mon, 27 May 2024 10:44:37 -0400 Message-ID: References: <86msobv3yy.fsf@gnu.org> <86le3vv3cc.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15107"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: n142857@gmail.com, 71223@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 27 16:45:05 2024 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 1sBbay-0003it-Ga for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 27 May 2024 16:45:04 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sBbap-0008W4-2H; Mon, 27 May 2024 10:44:55 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sBban-0008Tk-89 for bug-gnu-emacs@gnu.org; Mon, 27 May 2024 10:44:53 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sBbam-0002y8-VW for bug-gnu-emacs@gnu.org; Mon, 27 May 2024 10:44:52 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sBbav-0000rh-MW for bug-gnu-emacs@gnu.org; Mon, 27 May 2024 10:45:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 May 2024 14:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71223 X-GNU-PR-Package: emacs Original-Received: via spool by 71223-submit@debbugs.gnu.org id=B71223.17168210963299 (code B ref 71223); Mon, 27 May 2024 14:45:01 +0000 Original-Received: (at 71223) by debbugs.gnu.org; 27 May 2024 14:44:56 +0000 Original-Received: from localhost ([127.0.0.1]:45030 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sBbaq-0000r9-EV for submit@debbugs.gnu.org; Mon, 27 May 2024 10:44:56 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:42649) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sBbao-0000qw-Dh for 71223@debbugs.gnu.org; Mon, 27 May 2024 10:44:54 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 8842C100043; Mon, 27 May 2024 10:44:39 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1716821078; bh=YIX8gmMYnWkHUYOSJ5hWzqYuWH4t1UMAMAnYv+NJLss=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=AfHm8cuYXUMz2l+hCmN+nFLKa1uEVfKiI3KnE2le0VHogI+fHaFHSCi3JBZD/DxjY GdUouc9sGArR+aDFhJ089fj7Mb51EVuhb5v+xy+1IIeARfGeSfRCu3z9vLW+5+DYy7 tv0HTRHFw2aGYoaB2GyMcFl46HWkt9nmJEG22cg7pTCfPha2DCiHPQnI4nJB5XP6pd 63kRUeCd3nE05mtnAzkpDdUnk/1jTYSQQvuNzxAa1THr0f+OZoRvwBNT+WCnxInRcA StRqX0FIwVTSZQU2JZf4LjS5AbQbWMdAZAaXVkKU6XbMF2fJLSBI6VmxS3fSf/+NOr INVRUiYfz5VUg== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 6155710002E; Mon, 27 May 2024 10:44:38 -0400 (EDT) Original-Received: from pastel (unknown [45.72.201.106]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 375F7120351; Mon, 27 May 2024 10:44:38 -0400 (EDT) In-Reply-To: <86le3vv3cc.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 27 May 2024 15:36:35 +0300") 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:286044 Archived-At: > +(defun server--sit-for (proc seconds) > + "Like `sit-for', but disable filter of process PROC and don't redisplay." > + (let ((orig-filter (process-filter proc))) > + (unwind-protect > + (progn > + (set-process-filter proc nil) > + (sit-for seconds t)) > + (set-process-filter proc orig-filter)))) Hmm... (set-process-filter proc nil) means that any process output will be sent to the process's buffer rather than to the filter, which doesn't sound right (it will make us miss that process output, basically). If we want this to work well we need to store the process output we receive during the `sit-for` and call the process filter in it afterwards. Another option would be to offer a way to temporary suspend the reception of process output for a specific process. For most processes, suspending reception of process output while running the process filter would be the right thing to do, so even better would be to do that automatically and offer instead a way for a process filter to explicitly enable running itself recursively when/were it is needed. > ;; We use various special properties on process objects: > ;; - `env' stores the info about the environment of the emacsclient process. > ;; - `continuation' is a no-arg function that we need to execute. It contains > @@ -1159,7 +1168,7 @@ server-process-filter > ;; it, in case the error written by emacsclient to stderr is not > ;; visible for some reason. > (message "Authentication failed") > - (sit-for 2) > + (server--sit-for proc 2) > (server-send-string > proc (concat "-error " (server-quote-arg "Authentication failed"))) > (unless (eq system-type 'windows-nt) IIUC this `sit-for` is there to let the user see the message. It's a common source of problems. We should devise a variant of `message` which guarantees that the message is shown for at least N seconds but without having to wait for the N seconds to pass before running the rest of the code. > @@ -1169,7 +1178,7 @@ server-process-filter > (delete-terminal terminal)))) > ;; Before calling `delete-process', give emacsclient time to > ;; receive the error string and shut down on its own. > - (sit-for 1) > + (server--sit-for proc 1) > (delete-process proc) > ;; We return immediately. > (cl-return-from server-process-filter))) I think a better option here is to run the `delete-process` from a timer, so we can *really* return immediately. > @@ -1508,7 +1517,7 @@ server-return-error > ;; it, in case the error written by emacsclient to stderr is not > ;; visible for some reason. > (message (error-message-string err)) > - (sit-for 2) > + (server--sit-for proc 2) > (server-send-string > proc (concat "-error " (server-quote-arg > (error-message-string err)))) Same as the first `sit-for` above. > @@ -1520,7 +1529,7 @@ server-return-error > (delete-terminal terminal)))) > ;; Before calling `delete-process', give emacsclient time to > ;; receive the error string and shut down on its own. > - (sit-for 5) > + (server--sit-for proc 5) > (delete-process proc))) Same as the second `sit-for` above. Stefan