GNU bug report logs - #65051
internal_equal manipulates symbols with position without checking symbols-with-pos-enabled.

Previous Next

Package: emacs;

Reported by: Alan Mackenzie <acm <at> muc.de>

Date: Fri, 4 Aug 2023 14:01:02 UTC

Severity: normal

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Alan Mackenzie <acm <at> muc.de>
Subject: bug#65051: closed (Re: bug#65051: Acknowledgement (internal_equal
 manipulates symbols with position without checking symbols-with-pos-enabled.))
Date: Mon, 04 Sep 2023 12:58:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#65051: internal_equal manipulates symbols with position without checking symbols-with-pos-enabled.

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 65051 <at> debbugs.gnu.org.

-- 
65051: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=65051
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Alan Mackenzie <acm <at> muc.de>
To: 65051-done <at> debbugs.gnu.org
Cc: acm <at> muc.de
Subject: Re: bug#65051: Acknowledgement (internal_equal manipulates symbols
 with position without checking symbols-with-pos-enabled.)
Date: Mon, 4 Sep 2023 12:57:15 +0000
Bug fixed in the master branch, 2023-09-04.

-- 
Alan Mackenzie (Nuremberg, Germany).

[Message part 3 (message/rfc822, inline)]
From: Alan Mackenzie <acm <at> muc.de>
To: bug-gnu-emacs <at> gnu.org
Subject: internal_equal manipulates symbols with position without checking
 symbols-with-pos-enabled.
Date: Fri, 4 Aug 2023 14:00:29 +0000
Hello, Emacs.

The code in question is in internal_equal (src/fns.c) ~37 lines from its
start.  We have:

  if (SYMBOL_WITH_POS_P (o1))
    o1 = SYMBOL_WITH_POS_SYM (o1);
  if (SYMBOL_WITH_POS_P (o2))
    o2 = SYMBOL_WITH_POS_SYM (o2);

at the top level of the function.  Thus

    (equal 'foo #<symbol foo at 42>)

will return non-nil, regardless of the setting of
symbols-with-pos-enabled.  It should return non-nil only when that flag
variable is non-nil.  This is a bug.

#########################################################################

A simple fix is:



diff --git a/src/fns.c b/src/fns.c
index bfd19e8c8f2..b1f0c4ecdd6 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -2773,10 +2773,13 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, enum equal_kind equal_kind,
 
   /* A symbol with position compares the contained symbol, and is
      `equal' to the corresponding ordinary symbol.  */
-  if (SYMBOL_WITH_POS_P (o1))
-    o1 = SYMBOL_WITH_POS_SYM (o1);
-  if (SYMBOL_WITH_POS_P (o2))
-    o2 = SYMBOL_WITH_POS_SYM (o2);
+  if (symbols_with_pos_enabled)
+    {
+      if (SYMBOL_WITH_POS_P (o1))
+	o1 = SYMBOL_WITH_POS_SYM (o1);
+      if (SYMBOL_WITH_POS_P (o2))
+	o2 = SYMBOL_WITH_POS_SYM (o2);
+    }
 
   if (BASE_EQ (o1, o2))
     return true;


-- 
Alan Mackenzie (Nuremberg, Germany).



This bug report was last modified 1 year and 315 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.