From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Chang Xiaoduan Newsgroups: gmane.emacs.bugs Subject: bug#67900: 30.0.50; Emacs Crahes When Executing Command `consult-buffer' Date: Fri, 05 Jan 2024 15:04:26 +0800 Message-ID: References: <838r5qib7l.fsf@gnu.org> <83plz1ggua.fsf@gnu.org> <8334vwgezh.fsf@gnu.org> <83msu2fzvc.fsf@gnu.org> <834jg9fk2j.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18696"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 67900@debbugs.gnu.org, Eli Zaretskii To: Andrea Corallo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 05 08:05:22 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 1rLeGg-0004hc-Ex for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 05 Jan 2024 08:05:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rLeGK-0002qn-Sn; Fri, 05 Jan 2024 02:05:00 -0500 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 1rLeGI-0002qX-Eh for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2024 02:04:58 -0500 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 1rLeGI-0003nc-6m for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2024 02:04:58 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rLeGL-0007cn-PS for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2024 02:05:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Chang Xiaoduan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 05 Jan 2024 07:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67900 X-GNU-PR-Package: emacs Original-Received: via spool by 67900-submit@debbugs.gnu.org id=B67900.170443829529286 (code B ref 67900); Fri, 05 Jan 2024 07:05:01 +0000 Original-Received: (at 67900) by debbugs.gnu.org; 5 Jan 2024 07:04:55 +0000 Original-Received: from localhost ([127.0.0.1]:56205 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLeGE-0007cI-PV for submit@debbugs.gnu.org; Fri, 05 Jan 2024 02:04:55 -0500 Original-Received: from mail3-162.sinamail.sina.com.cn ([202.108.3.162]:45746) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLeG9-0007bx-69 for 67900@debbugs.gnu.org; Fri, 05 Jan 2024 02:04:53 -0500 X-SMAIL-HELO: PWRD-20210716KV Original-Received: from unknown (HELO PWRD-20210716KV)([111.207.225.84]) by sina.com (10.182.253.22) with ESMTP id 6597A9FA00003DA1; Fri, 5 Jan 2024 15:04:36 +0800 (CST) X-Sender: drcxd@sina.com X-Auth-ID: drcxd@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=drcxd@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=drcxd@sina.com X-SMAIL-MID: 3183776816529 X-SMAIL-UIID: 87DC651FC8DB4D4D971BAB81E23A1E84-20240105-150436-1 In-Reply-To: (Andrea Corallo's message of "Thu, 04 Jan 2024 04:51:26 -0500") 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:277358 Archived-At: Hello Andrea, I still doubt the method you suggest to locate the mis-compiled code here. Assume we have n functions all compiled with optimization level 2. Executing one of them, which may call the others, triggers a crash. Now if we make one of the function compiled with optimization level 1, and the crash can still be reproduced, then can we conclude that the function is not involved in the crash? I do not think so. Maybe that function and some other function both trigger the crash. Now assume we have n functions all compiled with optimization level 1 and no crash. Making one function compiled with optimization level 2 and the program crashes. I think now it is safe to conclude that this function is involved in the crash. The following is what I have done: 1. I mark all `defun' in consult.el with `(declare (speed 1))'. I can still reproduce the crash. 2. In addition to step 1, I mark all `cl-defun' in consult.el with `(declare (speed 1))'. I can still reproduce the crash. 3. In addition to step 2, I mark all `defmacro' in consult.el with `(declare (speed 1))'. I do not know if this works with `defmacro' or not, I do it anyway. I can still reproduce the crash. However, I notice one of the `defmacro' is somehow special: #+begin_src eamcs-lisp (defmacro consult--define-state (type) "Define state function for TYPE." (declare (speed 1)) `(defun ,(intern (format "consult--%s-state" type)) () ,(format "State function for %ss with preview. The result can be passed as :state argument to `consult--read'." type) (consult--state-with-return (,(intern (format "consult--%s-preview" type))) #',(intern (format "consult--%s-action" type))))) #+end_src >From what I know about "macro" in C, this will expand to a function definition. I assume this is also true in Emacs Lisp, so: 4. In addition to step 3, I add the `declare' form in the macro definition, and now the code is: #+begin_src emacs-lisp (defmacro consult--define-state (type) "Define state function for TYPE." (declare (speed 1)) `(defun ,(intern (format "consult--%s-state" type)) () ,(format "State function for %ss with preview. The result can be passed as :state argument to `consult--read'." type) (declare (speed 1)) (consult--state-with-return (,(intern (format "consult--%s-preview" type))) #',(intern (format "consult--%s-action" type))))) #+end_src Only after step 4, I can not reproduce the crash. If I regress to step 3, then the crash is reproducible. Thus, I think *at least* the function generated using this macro is involved in the crash. What do you think about it? Thank you