From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#41520: 28.0.50; Crash in character.h due to assertion error Date: Mon, 25 May 2020 17:18:25 +0300 Message-ID: <83imgkw11q.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="46483"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 41520@debbugs.gnu.org, stefan@marxist.se To: Pip Cet Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 25 16:19:11 2020 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 1jdDwd-000ByI-GN for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 25 May 2020 16:19:11 +0200 Original-Received: from localhost ([::1]:53056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jdDwc-0008Na-HR for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 25 May 2020 10:19:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jdDwU-0008NF-CL for bug-gnu-emacs@gnu.org; Mon, 25 May 2020 10:19:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58730) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jdDwU-00068z-3P for bug-gnu-emacs@gnu.org; Mon, 25 May 2020 10:19:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jdDwT-0001My-VJ for bug-gnu-emacs@gnu.org; Mon, 25 May 2020 10:19:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 25 May 2020 14:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41520 X-GNU-PR-Package: emacs Original-Received: via spool by 41520-submit@debbugs.gnu.org id=B41520.15904163175231 (code B ref 41520); Mon, 25 May 2020 14:19:01 +0000 Original-Received: (at 41520) by debbugs.gnu.org; 25 May 2020 14:18:37 +0000 Original-Received: from localhost ([127.0.0.1]:42043 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jdDvq-0001M1-CT for submit@debbugs.gnu.org; Mon, 25 May 2020 10:18:37 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:40912) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jdDvp-0001Lq-3V for 41520@debbugs.gnu.org; Mon, 25 May 2020 10:18:21 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:49892) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jdDvj-00064W-Dg; Mon, 25 May 2020 10:18:15 -0400 Original-Received: from [176.228.60.248] (port=4989 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jdDvi-0005Eg-Rc; Mon, 25 May 2020 10:18:15 -0400 In-Reply-To: (message from Pip Cet on Mon, 25 May 2020 07:28:23 +0000) 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" Xref: news.gmane.io gmane.emacs.bugs:180970 Archived-At: > From: Pip Cet > 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 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).