unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Pip Cet <pipcet@gmail.com>
Cc: 41520@debbugs.gnu.org, stefan@marxist.se
Subject: bug#41520: 28.0.50; Crash in character.h due to assertion error
Date: Mon, 25 May 2020 17:18:25 +0300	[thread overview]
Message-ID: <83imgkw11q.fsf@gnu.org> (raw)
In-Reply-To: <CAOqdjBe5CG5A7MGQ0hY7BZDi+EAwFczJ0MYxTPcxmVjxS_=J8Q@mail.gmail.com> (message from Pip Cet on Mon, 25 May 2020 07:28:23 +0000)

> From: Pip Cet <pipcet@gmail.com>
> Date: Mon, 25 May 2020 07:28:23 +0000
> Cc: 41520@debbugs.gnu.org
> 
> On Mon, May 25, 2020 at 7:06 AM Stefan Kangas <stefan@marxist.se> wrote:
> > When editing an org-mode document, I saw a crash due to this assertion
> > error:
> 
> It's a bug in this code in xdisp.c:
> 
>   else if (it->bidi_it.charpos == bob
>        || (!string_p
>            && (FETCH_CHAR (it->bidi_it.bytepos - 1) == '\n'
>            || FETCH_CHAR (it->bidi_it.bytepos) == '\n')))

Ouch!

> The first FETCH_CHAR should be a FETCH_BYTE to avoid the assertion error.
> 
> There's at least one other place that has the same error, so I'll grep
> some more before sending a patch.

Thanks.

> My suggestion is to drop the "eassume" on emacs-27, and fix FETCH_CHAR
> to FETCH_BYTE on master.

There's no eassume on emacs-27, this is new on master.  That is why
these problems were never exposed before: the old versions of macros
didn't signal any errors in these cases, they just produced some wrong
values, which can never be equal to a newline.

So I installed on emacs-27 branch a patch very similar to what you
sent, except that it uses FETCH_BYTE in all cases where we compare to
a newline: this is both more efficient and more correct.

> (I'd like to reiterate my proposal to use a pos_t for bytepos/charpos
> pairs, which would catch or silently fix (which happened in this case
> on my pos_t branch) such bugs. The code on my branch reads:
> 
>   else if (POS_CHAR_EQUAL (it->bidi_it.pos, bob)
>        || (!string_p
>            && (FETCH_CHAR (dec_pos (it->bidi_it.pos)) == '\n'
>            || FETCH_CHAR (it->bidi_it.pos) == '\n')))
> 
> which, while minimally slower, doesn't throw assertion errors.)

That would require us to maintain both character and byte positions
where we use these macros, something that could be redundant
overhead.  Moreover, I think we prefer having assertions in the debug
builds rather then silent fixups (and in production eassume compiles
into something that doesn't abort).





  parent reply	other threads:[~2020-05-25 14:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-25  7:05 bug#41520: 28.0.50; Crash in character.h due to assertion error Stefan Kangas
2020-05-25  7:28 ` Pip Cet
2020-05-25  7:41   ` Pip Cet
2020-05-25 14:18   ` Eli Zaretskii [this message]
2020-05-25 14:30     ` Pip Cet
2020-05-25 15:07       ` Eli Zaretskii
2020-05-25 15:16         ` Pip Cet
2020-05-25 16:09           ` Eli Zaretskii
2020-05-25 17:54             ` Pip Cet
2020-05-25 19:30               ` Eli Zaretskii
2020-05-25 20:39                 ` Pip Cet
2020-05-26 16:17                   ` Eli Zaretskii
2020-09-27 14:36         ` Lars Ingebrigtsen
2020-09-27 15:15           ` Eli Zaretskii
2020-09-27 15:42             ` Lars Ingebrigtsen
2020-09-27 16:00               ` Eli Zaretskii

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=83imgkw11q.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=41520@debbugs.gnu.org \
    --cc=pipcet@gmail.com \
    --cc=stefan@marxist.se \
    /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).