From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Corallo Newsgroups: gmane.emacs.bugs Subject: bug#67900: 30.0.50; Emacs Crahes When Executing Command `consult-buffer' Date: Fri, 05 Jan 2024 16:46:46 -0500 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="15892"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 67900@debbugs.gnu.org, Eli Zaretskii To: Chang Xiaoduan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 05 22:48:19 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 1rLs38-0003vH-LN for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 05 Jan 2024 22:48:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rLs2q-0007BX-Q4; Fri, 05 Jan 2024 16:48: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 1rLs2o-0007B8-B3 for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2024 16:47: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 1rLs2n-0001BD-SR for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2024 16:47:58 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rLs2s-0007Lr-CI for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2024 16:48:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Andrea Corallo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 05 Jan 2024 21:48:02 +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.170449123528064 (code B ref 67900); Fri, 05 Jan 2024 21:48:02 +0000 Original-Received: (at 67900) by debbugs.gnu.org; 5 Jan 2024 21:47:15 +0000 Original-Received: from localhost ([127.0.0.1]:58088 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLs26-0007IZ-V2 for submit@debbugs.gnu.org; Fri, 05 Jan 2024 16:47:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60000) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLs24-0007IL-C8 for 67900@debbugs.gnu.org; Fri, 05 Jan 2024 16:47:13 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rLs1r-0007fl-7C; Fri, 05 Jan 2024 16:46:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=Wl0Xk8fFOC3OULxMgIsi8M2i8g3gn1zzKbDcnOhNMrk=; b=hi1vjXMdk5AN4YnpqNbO E0imIDuPniMnJFLpOhwHapDEaRldfonv2Bd+StXeW8YOdR3n1wVA3cvYhqnbc0hjF2yQqor+9zW7R MEFsf0K97p96WwQo1iZDPenwPDBdK3I2yx/kMD4M8FePtRZyN2aiwipIVSdkCBaWBPP0q8D1h+2Cl O3NOpILN1uvrFxP33J0S2lFE02vEJPmmvE803IqLWmvLVuiwDJ4nVBsBZbATcZz5grgruqp9V3NB6 Pnyr01ko1SJ2B4udvx1j1lhJcgiD2czZ942mDqDt1+JrNMmE4/YHu9R9+sVBZ8b2UZahKGH/IV6Yj 5o08jTVUNiJOfA==; Original-Received: from acorallo by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1rLs1e-0001zX-H8; Fri, 05 Jan 2024 16:46:57 -0500 In-Reply-To: (Chang Xiaoduan's message of "Fri, 05 Jan 2024 15:04:26 +0800") 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:277419 Archived-At: Chang Xiaoduan writes: > 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? I think you did what I suggested, adding declares to narrow down the issue to defuns. The fact that some defun is macro generated and that one of these could have been the misscompiled one was as well suggested by me in this thread. I think the best now is to macro expand all those function and keep on using the suggested declare method to narrow down exactly which of the generated functions is the problematic one. Thanks Andrea