unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Andrea Corallo <acorallo@gnu.org>
To: Chang Xiaoduan <drcxd@sina.com>
Cc: 67900@debbugs.gnu.org, Eli Zaretskii <eliz@gnu.org>
Subject: bug#67900: 30.0.50; Emacs Crahes When Executing Command `consult-buffer'
Date: Fri, 05 Jan 2024 16:46:46 -0500	[thread overview]
Message-ID: <yp1r0ivwj09.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <m3cyugclc5.fsf@sina.com> (Chang Xiaoduan's message of "Fri, 05 Jan 2024 15:04:26 +0800")

Chang Xiaoduan <drcxd@sina.com> 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





  reply	other threads:[~2024-01-05 21:46 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-19  7:48 bug#67900: 30.0.50; Emacs Crahes When Executing Command `consult-buffer' Chang Xiaoduan
2023-12-19 13:16 ` Eli Zaretskii
     [not found]   ` <m3msu5751x.fsf@sina.com>
2023-12-20 13:10     ` Eli Zaretskii
2023-12-21  3:26       ` Chang Xiaoduan
2023-12-21  8:02         ` Eli Zaretskii
2023-12-21 12:40           ` Andrea Corallo
2023-12-22  3:44             ` Chang Xiaoduan
2023-12-22  7:41               ` Eli Zaretskii
2023-12-22  9:38                 ` Andrea Corallo
2023-12-23  2:30                 ` Chang Xiaoduan
2023-12-23  7:35                   ` Eli Zaretskii
2023-12-26  8:32                     ` Andrea Corallo
2023-12-28 11:44                       ` Chang Xiaoduan
2023-12-29 18:37                         ` Andrea Corallo
2024-01-02  7:24                           ` Chang Xiaoduan
2024-01-04  9:51                             ` Andrea Corallo
2024-01-05  7:04                               ` Chang Xiaoduan
2024-01-05 21:46                                 ` Andrea Corallo [this message]
2024-01-08  3:28                                   ` Chang Xiaoduan
2024-01-08 10:35                                     ` Andrea Corallo
2024-01-08 11:40                                       ` Chang Xiaoduan
2024-01-09  9:58                                         ` Andrea Corallo
2024-01-02  8:20                           ` Chang Xiaoduan
2024-01-04  9:58                             ` Andrea Corallo
2024-01-05  4:22                             ` Richard Stallman
2024-01-05  7:09                               ` Chang Xiaoduan
2024-01-07  4:29                                 ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yp1r0ivwj09.fsf@fencepost.gnu.org \
    --to=acorallo@gnu.org \
    --cc=67900@debbugs.gnu.org \
    --cc=drcxd@sina.com \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).