unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: 48061@debbugs.gnu.org
Subject: bug#48061: Unexpected result from a native-compiled function
Date: Tue, 27 Apr 2021 14:49:31 +0000	[thread overview]
Message-ID: <YIgke29Sk67WStXQ@ACM> (raw)

Hello, Emacs.

In certain circumstances (see below for recipe), the natively compiled
version of c-determine-limit-no-macro returns an invalid result, nil.
In the same circumstances, the edebug instrumented version returns the
correct result, a buffer position.

So far I have tried M-x disassemble RET c-determine-limit-no-macro, but
I wasn't able to follow the output (there were no symbols in the
listing).

Question: what else can I do to help isolate and fix this bug?

Recipe for reproduction:

In GNU Emacs 28.0.50 (build 4, x86_64-pc-linux-gnu, GTK+ Version
3.24.26, cairo version 1.16.0)
 of 2021-04-25 built on ACM
Repository revision: 83a915d3dfafd5f3d737afe1e13b75e4dd3aef96
Repository branch: master
System Description: Gentoo/Linux

Configured using:
 'configure --with-gif=no --with-tiff=no --with-gpm
 --with-native-compilation'


(i) emacs -Q
(ii) Make sure CC Mode is natively compiled and loaded into an Emacs
session.
(iii) Evaluate the following (an attempt to time CC Mode's indentation
speed):

(defmacro time-it (&rest forms)
  "Time the running of a sequence of forms using `float-time'.
Call like this: \"M-: (time-it (foo ...) (bar ...) ...)\"."
  `(let ((start (float-time)))
    ,@forms
    (- (float-time) start)))

(defun time-indent ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (while (not (eobp))
      (delete-horizontal-space)
      (beginning-of-line 2))
    (goto-char (point-min))
    (message "%s"
             (time-it
              (while (not (eobp))
                (c-indent-line)
                (beginning-of-line 2))))))

(iv) Load src/minibuf.c into a buffer.
(v) M-: (time-indent) RET
  This throws an error at line 606 in minibuf.c.  point is at 16972, at
BOL.

(vi) With the current buffer minibuf.c, M-: (c-determine-limit-no-macro
16367 16972) RET.  This returns the invalid result nil.  This looks like
a bug.

(vii) Load lisp/progmodes/cc-engine.el into another buffer.  Move to the
definition of c-determine-limit-no-macro at line 5795.  Instrument the
function for edebug with C-u C-M-x.

(viii) M-: (c-determine-limit-no-macro 16367 16972) RET, followed by the
edebug command c.  This indicates the expected result 16350, which is
different from the nil returned in (vi).


-- 
Alan Mackenzie (Nuremberg, Germany).





             reply	other threads:[~2021-04-27 14:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-27 14:49 Alan Mackenzie [this message]
2021-04-27 17:20 ` bug#48061: Unexpected result from a native-compiled function Alan Mackenzie
2021-04-27 20:02   ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-04-27 21:03     ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-04-28  9:19       ` Alan Mackenzie

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=YIgke29Sk67WStXQ@ACM \
    --to=acm@muc.de \
    --cc=48061@debbugs.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).