From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#72802: 31.0.50; Crash in (equal sub-char-table-a sub-char-table-b) Date: Sun, 25 Aug 2024 14:11:17 +0000 Message-ID: <87v7zo3d6m.fsf@protonmail.com> References: <871q2c4uf6.fsf@protonmail.com> Reply-To: Pip Cet Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25586"; mail-complaints-to="usenet@ciao.gmane.io" To: 72802@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Aug 25 16:12:27 2024 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 1siDyk-0006Vo-SW for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 25 Aug 2024 16:12:27 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1siDyX-0005fC-CC; Sun, 25 Aug 2024 10:12:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1siDyW-0005f2-Lx for bug-gnu-emacs@gnu.org; Sun, 25 Aug 2024 10:12:12 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1siDyW-00083b-Cp for bug-gnu-emacs@gnu.org; Sun, 25 Aug 2024 10:12:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:From:Date:To:In-Reply-To:References:Subject; bh=vhMxdBuTA99ucwdPPnVjWjQAaz4WBnZnkrrXWr7Wyi8=; b=o5ZsSMSZFU7NwukhDGkYHSo6+T47rprAl2IuL92aNwUUxJrNWtUHoH84Sc+yIaGlyKd44jYxdLrG3YJNOFXpSZ8p8JbKmXI/ARQm9EL6aU9ViYj65LFeeXPv7uuWZJvBks8L8DxmyACXptmg2+ktQMpLv3j981M8mQOrUrVJ43CWQvmooXhLpDAGjjhaPbjfTzFzj+N3B6xVRnuX59VErW1BUMFIpVmwCgr9QmQbYoHUqYWtP9+kKnTk3hsOqcuW5Xac+5NzLhMtBehlPFCmNztShKZ11wjKb/OhUfkqGzts8CBxNads8yoQIzD1v1Ouf9p8qs0xVTJqaGM22DcMrg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1siDzK-0007Zm-9d for bug-gnu-emacs@gnu.org; Sun, 25 Aug 2024 10:13:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <871q2c4uf6.fsf@protonmail.com> Resent-From: Pip Cet Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 25 Aug 2024 14:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72802 X-GNU-PR-Package: emacs Original-Received: via spool by 72802-submit@debbugs.gnu.org id=B72802.172459514129052 (code B ref 72802); Sun, 25 Aug 2024 14:13:02 +0000 Original-Received: (at 72802) by debbugs.gnu.org; 25 Aug 2024 14:12:21 +0000 Original-Received: from localhost ([127.0.0.1]:43104 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1siDyf-0007YW-7W for submit@debbugs.gnu.org; Sun, 25 Aug 2024 10:12:21 -0400 Original-Received: from mail-4316.protonmail.ch ([185.70.43.16]:59535) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1siDyc-0007Y8-57 for 72802@debbugs.gnu.org; Sun, 25 Aug 2024 10:12:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1724595081; x=1724854281; bh=vhMxdBuTA99ucwdPPnVjWjQAaz4WBnZnkrrXWr7Wyi8=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=XBJPpjJtRKidkGnwI5cTLVYRwHJeqJEJQlDWFeg9xbPqfM8YdSJUjzf7n283b4+ns JyRdbTZildeYVbHNf/exOS81h5EDV+Ro2ZdTuOSxFGkgtljMAEdUy8xtp4i9us/i2G nVm5oy5JOIyOJ1b0JYiAZnodeJztN238VzPWPPjWGisX7RLeizzWS8m2YPJdd0tPQk ZhxVpv+YbxV627Sp+ofHr6kox0TTXeQnDpjwKi058xXEEVXOj1SFb4zx5/7uRqoP7E 05Vsya8AEYTimnD0NUEWm62lvy1ZiGCYSaLJQ6Af1EH/oN2lVlXUWNGq04i5nRlcWs yl067vbM69mRA== Feedback-ID: 112775352:user:proton X-Pm-Message-ID: 6b1ff51a8c0184f0ea5b0aec039f58ada2e876a5 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:290739 Archived-At: Pip Cet writes: > The code in internal_equal compares sub-char-tables incorrectly This patch should fix things for the release branch: >From df31249b3686c38e4816cfa2784c25443a61b749 Mon Sep 17 00:00:00 2001 From: Pip Cet Subject: [PATCH] Fix crashes when comparing sub char tables (Bug#72802) * src/fns.c (internal_equal): Handle sub char tables specially, like 'mark_char_table' does. --- src/fns.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/fns.c b/src/fns.c index 57113a8c5ed..cb799a13a6e 100644 --- a/src/fns.c +++ b/src/fns.c @@ -2948,14 +2948,28 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, enu= m equal_kind equal_kind, =09/* Aside from them, only true vectors, char-tables, compiled =09 functions, and fonts (font-spec, font-entity, font-object) =09 are sensible to compare, so eliminate the others now. */ +=09ptrdiff_t i =3D 0; =09if (size & PSEUDOVECTOR_FLAG) =09 { =09 if (((size & PVEC_TYPE_MASK) >> PSEUDOVECTOR_AREA_BITS) =09=09< PVEC_CLOSURE) =09 return false; + +=09 /* Bug#72802. See 'mark_char_table' in alloc.c. */ +=09 if (SUB_CHAR_TABLE_P (o1)) +=09 { +=09=09i =3D SUB_CHAR_TABLE_OFFSET; +=09=09if (XSUB_CHAR_TABLE (o1)->depth !=3D +=09=09 XSUB_CHAR_TABLE (o2)->depth) +=09=09 return false; +=09=09if (XSUB_CHAR_TABLE (o1)->min_char !=3D +=09=09 XSUB_CHAR_TABLE (o2)->min_char) +=09=09 return false; +=09 } + =09 size &=3D PSEUDOVECTOR_SIZE_MASK; =09 } -=09for (ptrdiff_t i =3D 0; i < size; i++) +=09for (; i < size; i++) =09 { =09 Lisp_Object v1, v2; =09 v1 =3D AREF (o1, i); --=20 2.45.2 Okay for emacs-30 (and/or master, though I'd prefer to fix it differently on that branch)? For the master branch, I think the right thing to do is to turn the first two, non-Lisp members of Lisp_Sub_Char_Table ('depth' and 'min_char') into 'Lisp_Object's. Then we can simplify the code and compare sub char tables as we do ordinary vectors, at the cost of eight bytes of extra storage per sub char table on machines with 64-bit EMACS_INTs. BTW, I'm surprised this code returns nil; I think that should be documented. (setq a (make-char-table nil)) (setq b (make-char-table nil)) (aset a 1 nil) (dotimes (i (max-char)) (unless (equal (aref a i) (aref b i)) (error "i =3D %S" i))) (equal a b) Pip