From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.bugs Subject: bug#41520: 28.0.50; Crash in character.h due to assertion error Date: Mon, 25 May 2020 14:30:55 +0000 Message-ID: References: <83imgkw11q.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="000000000000d075f505a679d583" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="102310"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 41520@debbugs.gnu.org, stefan@marxist.se To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 25 16:32:18 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 1jdE9K-000Qaj-3H for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 25 May 2020 16:32:18 +0200 Original-Received: from localhost ([::1]:35050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jdE9J-0005sa-5C for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 25 May 2020 10:32:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49716) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jdE94-0005rn-5b for bug-gnu-emacs@gnu.org; Mon, 25 May 2020 10:32:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58762) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jdE93-00083c-OZ for bug-gnu-emacs@gnu.org; Mon, 25 May 2020 10:32:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jdE93-0001hD-Lg for bug-gnu-emacs@gnu.org; Mon, 25 May 2020 10:32:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Pip Cet Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 25 May 2020 14:32: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.15904170996492 (code B ref 41520); Mon, 25 May 2020 14:32:01 +0000 Original-Received: (at 41520) by debbugs.gnu.org; 25 May 2020 14:31:39 +0000 Original-Received: from localhost ([127.0.0.1]:42075 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jdE8g-0001ge-Ln for submit@debbugs.gnu.org; Mon, 25 May 2020 10:31:39 -0400 Original-Received: from mail-ot1-f50.google.com ([209.85.210.50]:38306) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jdE8f-0001gS-KD for 41520@debbugs.gnu.org; Mon, 25 May 2020 10:31:38 -0400 Original-Received: by mail-ot1-f50.google.com with SMTP id o13so13951977otl.5 for <41520@debbugs.gnu.org>; Mon, 25 May 2020 07:31:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=B2DjAQ3RimNft/MtyzTebljnkxGpfCchFw829rO3hME=; b=FA2EETlMZKQXXjsGKHB93MGGVdxOf2GzrFhN/YfrIH7G4W9jwS41UukjF9YindPmOi 1owxX9CRfiYqS86w4HYeRXkGwpeejUyNenA+6p+Qssi8xyrBkxh5fxvY2D2ptuDv3TNr J5mmbw6IyFJbhzy3AUmfCChbLGOP2ADeiIeok9RFiKBL/UXW9dsHTxn0zNLC2N64RRrj 3RCT4py7Rrur4cFxisfuBhgLB5mo0Qr+kItFmrvKSbtosFKLqYfNJCse6MUUbjG9XHn2 wJX9B52/6i8sdMFBjmDzBn3qhUUr8akSEIcCeS49QO3Rr4OArG5uzDGzpFw05Lb+LUb2 ZefA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=B2DjAQ3RimNft/MtyzTebljnkxGpfCchFw829rO3hME=; b=s1TxaJ0SfmLj/Sp5BAlQUpxSQUxjsBLROxVaHiTv6L1UHH6nPdjw+Sj6hzvED+sb2D nHHKii8jgEg88werfepfadQCXGgWC7gG3WhxH4a0jM6Yagiu1+BmdcSXkH6cCS70GNJr WUnzi/x1490/MZlat4Ql5KAlmBehFzCWXR6qs01f831wwMFFOYTucNTXFIiU20nqt+lU 4P/1xHkYKRGyIMQA0elNXEDbsWUhSqeGi8n6v1Gqmb6ZHnZESXpYYZTr5NsgrSvkjfiN GRxeLdkVn3t3RRvGNpcZhCwLkNRXcjooVIH+SU9WdpUZZ6ua5EDice5i93CHnWelVAKL Tsdg== X-Gm-Message-State: AOAM532m4X8sOKrOsL0X99N1L5XzTQaFFA+CbPM/zlYOw8l1zcaunFTo 3fyAE12zLEpkkt0Hn1KrIsZGZQABTKdkQTm7RsE= X-Google-Smtp-Source: ABdhPJzX1Ch7jx9e8Sgim99qTCOUeNf67o57izSHiyw0XG2v+06qyG6Oi0tAwUiNRaVwl/Bfw33bxI97LHUeoAU8m+w= X-Received: by 2002:a9d:6a44:: with SMTP id h4mr21840907otn.287.1590417092007; Mon, 25 May 2020 07:31:32 -0700 (PDT) In-Reply-To: <83imgkw11q.fsf@gnu.org> 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:180972 Archived-At: --000000000000d075f505a679d583 Content-Type: text/plain; charset="UTF-8" On Mon, May 25, 2020 at 2:18 PM Eli Zaretskii wrote: > > From: Pip Cet > > Date: Mon, 25 May 2020 07:28:23 +0000 > > Cc: 41520@debbugs.gnu.org > > 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. Yeah, I realized after hitting "Send" that I'd looked at the wrong tree :-) > 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'm attaching a patch with a few more cases. I don't have a strong preference for either FETCH_BYTE or FETCH_CHAR where both will do, but we should be consistent. > > (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, For now, I'd like to introduce them in Emacs proper only where we have pairs of variables anyway. > something that could be redundant > overhead. It would be redundant to use a pos_t where a ptrdiff_t suffices, yes. I'm not proposing to do that at present, though I think there are some places that do charpos/bytepos conversions unnecessarily because only one of them is passed down the call chain. So, no, it wouldn't be redundant overhead, and it might actually make some code paths faster. > 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). I see no way to have assertions, and I think free bug fixes are better than undiscovered bugs. It's really hard to get things wrong with a stronger type. --000000000000d075f505a679d583 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-Fix-more-single-byte-accesses.patch" Content-Disposition: attachment; filename="0001-Fix-more-single-byte-accesses.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kaml8ysn0 RnJvbSA3MDJlZmFkZTdhNWJiNzU5ZjFkNmRmMDdlMjAxODBiYTk1ZDg3ZjNkIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBQaXAgQ2V0IDxwaXBjZXRAZ21haWwuY29tPgpEYXRlOiBNb24s IDI1IE1heSAyMDIwIDE0OjIwOjQ2ICswMDAwClN1YmplY3Q6IFtQQVRDSF0gRml4IG1vcmUgc2lu Z2xlLWJ5dGUgYWNjZXNzZXMuCgotLS0KIHNyYy9jbWRzLmMgICB8IDIgKy0KIHNyYy9zeW50YXgu YyB8IDQgKy0tLQogc3JjL3hkaXNwLmMgIHwgNiArKystLS0KIDMgZmlsZXMgY2hhbmdlZCwgNSBp bnNlcnRpb25zKCspLCA3IGRlbGV0aW9ucygtKQoKZGlmZiAtLWdpdCBhL3NyYy9jbWRzLmMgYi9z cmMvY21kcy5jCmluZGV4IDk5MTRiN2EwMWYuLjJkZDY4ZWUwNjcgMTAwNjQ0Ci0tLSBhL3NyYy9j bWRzLmMKKysrIGIvc3JjL2NtZHMuYwpAQCAtMzk5LDcgKzM5OSw3IEBAIGludGVybmFsX3NlbGZf aW5zZXJ0IChpbnQgYywgRU1BQ1NfSU5UIG4pCiAJCSAgICAgYnkgc3BhY2VzIHNvIHRoYXQgdGhl IHJlbWFpbmluZyB0ZXh0IHdvbid0IG1vdmUuICAqLwogCQkgIHB0cmRpZmZfdCBhY3R1YWwgPSBQ VF9CWVRFOwogCQkgIERFQ19QT1MgKGFjdHVhbCk7Ci0JCSAgaWYgKEZFVENIX0NIQVIgKGFjdHVh bCkgPT0gJ1x0JykKKwkJICBpZiAoRkVUQ0hfQllURSAoYWN0dWFsKSA9PSAnXHQnKQogCQkgICAg LyogUmF0aGVyIHRoYW4gYWRkIHNwYWNlcywgbGV0J3MganV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