From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii 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 17:50:11 +0300 Message-ID: <86a5h0lkrg.fsf@gnu.org> References: <871q2c4uf6.fsf@protonmail.com> <87v7zo3d6m.fsf@protonmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1535"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 72802@debbugs.gnu.org To: Pip Cet Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Aug 25 16:51:37 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 1siEaf-0000Hd-06 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 25 Aug 2024 16:51:37 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1siEaJ-0002CB-OV; Sun, 25 Aug 2024 10:51:15 -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 1siEaH-0002BQ-8P for bug-gnu-emacs@gnu.org; Sun, 25 Aug 2024 10:51:13 -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 1siEaG-0005jn-VV for bug-gnu-emacs@gnu.org; Sun, 25 Aug 2024 10:51:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=BH4IGuCgdfm6DMYUn7bD4ulG6+2Y1vl8SkY58/m2F4E=; b=hfdoHbQJZitBimACd8aSiKIAOlWvckjw4xrZN+d9ImlWlHfs6aW2WibfgP9EOOAmTG2Z7VeebegSfdQDCKRJE7PAOuMC2I9M5GyMo2lvgoy0Fe8XLaKJlDEcQ6IUj+rRVaTSO3wgjWu/sdl+i9uF/faCy0GjhEIkCmgV2TJAA4Ho7bJsZB2HGQujGr+OVfDic/7mf6aV0isISP8lJsGdiM95XW/Wcx64oAAYGhu5qUo0kR1nM4JuUEERJTTiiq0Dcell53yvHp2peHnc5OB5ebIHLaJJ4N7f2FEx6XOzlozSD+NXOgUWqCOTj+6WvEJ8T1yOEikiG7XlkhfwD/4H9w==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1siEb3-0000GB-Tg for bug-gnu-emacs@gnu.org; Sun, 25 Aug 2024 10:52: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: Sun, 25 Aug 2024 14:52:01 +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.1724597495959 (code B ref 72802); Sun, 25 Aug 2024 14:52:01 +0000 Original-Received: (at 72802) by debbugs.gnu.org; 25 Aug 2024 14:51:35 +0000 Original-Received: from localhost ([127.0.0.1]:43145 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1siEad-0000FL-3r for submit@debbugs.gnu.org; Sun, 25 Aug 2024 10:51:35 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:50852) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1siEab-0000Ex-By for 72802@debbugs.gnu.org; Sun, 25 Aug 2024 10:51:34 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1siEZg-0005cx-Au; Sun, 25 Aug 2024 10:50:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=BH4IGuCgdfm6DMYUn7bD4ulG6+2Y1vl8SkY58/m2F4E=; b=YXQYR+lwYCoo MGU2HZMommkq5VALSxXEEfZWYV57OPCdVkp+QlvjnI7ip8o6qwuy3JBcUTFZ7wBX5C3xYLFhvmtUy ynHE4x3HY6E3N1y0EzPYOfgR5JblKWJPnouCUWThCtztbzsIXovCevV/xf2vMlFeJmBuTOE1A0J0m TZteUI+lUoxOLufUUewA/VO210stao9MmbWUGjJhLcmlNEoahKIMueLb3vjARLQn4knFmeJztVBJ3 cXeevEu5TCuc3cTrYS6AtsaqSW/aCPXLFl1y4Rk+rfrAuCvtYrhhGKrK8qI+hvpktaOeRVkcqIyYz /aoeOVgW+1QMGVPi44ElKg==; In-Reply-To: <87v7zo3d6m.fsf@protonmail.com> (bug-gnu-emacs@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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:290740 Archived-At: > Date: Sun, 25 Aug 2024 14:11:17 +0000 > From: Pip Cet via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > Pip Cet writes: > > The code in internal_equal compares sub-char-tables incorrectly > > This patch should fix things for the release branch: I don't see a reason to install this on the release branch now. Not even on master, I think, unless we see a bug related to it that is not caused by a specially-concocted Lisp program or GDB command. If this is required for the no-pure-space branch, I think you should install this on that branch. Then it will be merged together with the branch. If you see some urgent need to fix this ASAP on master, please tell why you think so. > + /* Bug#72802. See 'mark_char_table' in alloc.c. */ > + if (SUB_CHAR_TABLE_P (o1)) > + { > + i = SUB_CHAR_TABLE_OFFSET; > + if (XSUB_CHAR_TABLE (o1)->depth != > + XSUB_CHAR_TABLE (o2)->depth) > + return false; > + if (XSUB_CHAR_TABLE (o1)->min_char != > + XSUB_CHAR_TABLE (o2)->min_char) > + return false; > + } I looked at mark_char_table, trying to understand what the above comments wants to say, and couldn't. So I think the comment should be improved, so that it would be more clear what it wants to say. Also, please move the assignment of SUB_CHAR_TABLE_OFFSET to i to after the two early 'return's. > 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. I'm not sure we want to pay this cost. What bothers me is mainly the run-time cost of extracting integers from Lisp objects. char-table is supposed to be very efficient, both memory-wise and CPU-wise, and I think the performance here trumps simplicity. > 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 = %S" i))) > (equal a b) Why are you surprised? Setting a single cell of a char-table changes its structure, usually in quite a radical way. 'aref' does some very special things for char-tables; the semantics of accessing an element of a vector is only correct superficially, not in the details. The internals of a char-table are not really documented in the ELisp manual; the description there is mostly phenomenological, without any details. If you want to document the internals, I think the proper place is to add a comment at the beginning of chartab.c with these details (and there are a lot of details not really documented anywhere, at least not explicitly), and then this nit should be part of that.