GNU bug report logs - #32503
26.1; Byte-compiled functions don't hash consistently

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Adam Porter <adam@HIDDEN>; dated Wed, 22 Aug 2018 19:01:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 32503 <at> debbugs.gnu.org:


Received: (at 32503) by debbugs.gnu.org; 23 Aug 2018 01:42:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Aug 22 21:42:50 2018
Received: from localhost ([127.0.0.1]:58188 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1fseeA-0006AD-DK
	for submit <at> debbugs.gnu.org; Wed, 22 Aug 2018 21:42:50 -0400
Received: from gateway23.websitewelcome.com ([192.185.50.107]:32970)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <tom@HIDDEN>) id 1fsee6-00069z-7l
 for 32503 <at> debbugs.gnu.org; Wed, 22 Aug 2018 21:42:47 -0400
Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20])
 by gateway23.websitewelcome.com (Postfix) with ESMTP id 909F711422
 for <32503 <at> debbugs.gnu.org>; Wed, 22 Aug 2018 20:42:45 -0500 (CDT)
Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP
 id sedZfZErePvAdsedsfXla2; Wed, 22 Aug 2018 20:42:44 -0500
X-Authority-Reason: nr=8
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; 
 s=default;
 h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=wBBpCaoFLTboBzfC9stHiAcSuI1X9wf7hzJ62oG2PmI=; b=nTvXjaSCHmXSiEOS4WSSsvPv7L
 cqBGlQQT8aK23O0TuZucQf8gDVIBA/kXzX9gRaUytTlBjs7mvozPcO9x6VGZKHu5bujYKm4OQTzrk
 M11Aa36GUOzSB3ZwCgY0q8PRk;
Received: from 75-166-85-72.hlrn.qwest.net ([75.166.85.72]:42144 helo=bapiya)
 by box5379.bluehost.com with esmtpsa
 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91)
 (envelope-from <tom@HIDDEN>)
 id 1fsedZ-003ABT-LN; Wed, 22 Aug 2018 20:42:13 -0500
From: Tom Tromey <tom@HIDDEN>
To: Adam Porter <adam@HIDDEN>
Subject: Re: bug#32503: 26.1; Byte-compiled functions don't hash consistently
References: <CAO_b3FV+BOeguJU+UFpfo6VnrJ9Q5ympyeX61RHaKQhtcyhfug@HIDDEN>
X-Attribution: Tom
Date: Wed, 22 Aug 2018 19:42:12 -0600
In-Reply-To: <CAO_b3FV+BOeguJU+UFpfo6VnrJ9Q5ympyeX61RHaKQhtcyhfug@HIDDEN>
 (Adam Porter's message of "Wed, 22 Aug 2018 14:00:28 -0500")
Message-ID: <87efep3ll7.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-AntiAbuse: This header was added to track abuse,
 please include it with any abuse report
X-AntiAbuse: Primary Hostname - box5379.bluehost.com
X-AntiAbuse: Original Domain - debbugs.gnu.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - tromey.com
X-BWhitelist: no
X-Source-IP: 75.166.85.72
X-Source-L: No
X-Exim-ID: 1fsedZ-003ABT-LN
X-Source: 
X-Source-Args: 
X-Source-Dir: 
X-Source-Sender: 75-166-85-72.hlrn.qwest.net (bapiya) [75.166.85.72]:42144
X-Source-Auth: tom+tromey.com
X-Email-Count: 2
X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20=
X-Local-Domain: yes
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 32503
Cc: 32503 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Adam> I noticed that byte-compiled functions don't hash consistently.

The Lisp_Vectorlike case in Fequal has a number of special cases which
don't seem to be reflected in sxhash:

	if (OVERLAYP (o1))
[...]
	if (MARKERP (o1))
[...]
	if (WINDOW_CONFIGURATIONP (o1))
[...]
	/* Aside from them, only true vectors, char-tables, compiled
	   functions, and fonts (font-spec, font-entity, font-object)
	   are sensible to compare, so eliminate the others now.  */

(Bignums and bool vectors are special-cased as well but are handled in
sxhash.)  This is followed by code to loop over the pseudovector's
elements.

However, the Lisp_Vectorlike case in sxhash doesn't do any of this.

Probably there should be a rule that adding a new type should
necessitate adding a new hasher (much like how print syntax is needed);
or certainly if the type has non-trivial equal behavior.

Tom




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#32503; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 22 Aug 2018 19:00:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Aug 22 15:00:56 2018
Received: from localhost ([127.0.0.1]:57984 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1fsYND-0001dH-Mx
	for submit <at> debbugs.gnu.org; Wed, 22 Aug 2018 15:00:55 -0400
Received: from eggs.gnu.org ([208.118.235.92]:50612)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <alphadeltapapa@HIDDEN>) id 1fsYNC-0001d1-Cs
 for submit <at> debbugs.gnu.org; Wed, 22 Aug 2018 15:00:54 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <alphadeltapapa@HIDDEN>) id 1fsYN5-0003hZ-6H
 for submit <at> debbugs.gnu.org; Wed, 22 Aug 2018 15:00:48 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_20,FREEMAIL_FROM
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:39270)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <alphadeltapapa@HIDDEN>)
 id 1fsYN4-0003hF-57
 for submit <at> debbugs.gnu.org; Wed, 22 Aug 2018 15:00:47 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:43358)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <alphadeltapapa@HIDDEN>) id 1fsYN3-0007uA-AZ
 for bug-gnu-emacs@HIDDEN; Wed, 22 Aug 2018 15:00:46 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <alphadeltapapa@HIDDEN>) id 1fsYMz-0003eF-K5
 for bug-gnu-emacs@HIDDEN; Wed, 22 Aug 2018 15:00:45 -0400
Received: from mail-ed1-f50.google.com ([209.85.208.50]:38603)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <alphadeltapapa@HIDDEN>)
 id 1fsYMz-0003dU-Aa
 for bug-gnu-emacs@HIDDEN; Wed, 22 Aug 2018 15:00:41 -0400
Received: by mail-ed1-f50.google.com with SMTP id q15-v6so2047593eds.5
 for <bug-gnu-emacs@HIDDEN>; Wed, 22 Aug 2018 12:00:40 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to
 :content-transfer-encoding;
 bh=KrYiidulSaX+M2x7lTOTnMDmq02C9y8PJJisY6ADQ3E=;
 b=JLymqkOkLoIGAUl4IwfXuFhXJB350m2wImOGmQi82ytPppwROdjcP0N19d4B5Ioz3n
 cNR2pObL4U/PJNf0T0xQt/2sN/nd6FLZu/QGMvUpqZP1CXRUQ8xe3FWg+dNYt8G2EyRZ
 0Apm3e7O9IVfw0swISWSxjRgD46J7qQNuJ7TsDTRFbFXIV/hC1jzn0lHqBaoelhuNSic
 ohfRE25AI7v1iDUNJydpYQDnsyobszENAGybH517FLF8bH0oZhTwkrgCdmRlTlmJ0wLg
 t087c5U/xLXFxQxp49gGp65MSuWjOeWd4wEs4dadNeqnCO2PJHBWO7lxIyHSWh/HOJJL
 Xv4Q==
X-Gm-Message-State: AOUpUlE/WjZtqsi7P9/3mgPMUwroMD+nC9iqNFixvqdifNYoME1GsHFx
 1r5AOUTZd4AtRDObq4Mr2fCLB6rBB5PvumsyOGptW3UV
X-Google-Smtp-Source: AA+uWPyQzBnvbKI0Akzq/NZ7zd+JpqyxGMB5kdayZVyTeljzjftVhfY5kPJcHjwpJRqeasZyUErW7WVX+MTv0vmA5fY=
X-Received: by 2002:a50:c201:: with SMTP id
 n1-v6mr67645493edf.11.1534964439954; 
 Wed, 22 Aug 2018 12:00:39 -0700 (PDT)
MIME-Version: 1.0
From: Adam Porter <adam@HIDDEN>
Date: Wed, 22 Aug 2018 14:00:28 -0500
Message-ID: <CAO_b3FV+BOeguJU+UFpfo6VnrJ9Q5ympyeX61RHaKQhtcyhfug@HIDDEN>
Subject: 26.1; Byte-compiled functions don't hash consistently
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -3.8 (---)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.8 (----)

I noticed that byte-compiled functions don't hash consistently.  Here's
an ECM from Noam Postavsky
<https://github.com/skeeto/emacs-memoize/pull/10#issuecomment-415066682>:

    (let ((obj1 (byte-compile (lambda (x) x)))
          (obj2 (byte-compile (lambda (x) x))))
      (list (equal obj1 obj2)
            (eq obj1 obj2)
            (=3D (sxhash obj1)
               (sxhash obj2))))
    ;=3D> (t nil nil)

According to "(elisp) Defining Hash":

    If two objects OBJ1 and OBJ2 are equal, then =E2=80=98(sxhash OBJ1)=E2=
=80=99 and
    =E2=80=98(sxhash OBJ2)=E2=80=99 are the same integer.

This makes it impossible to use byte-compiled functions as keys or parts
of keys in hash tables.  A workaround is to `prin1-to-string` the
byte-compiled function and use that as the key.

Thanks.




Acknowledgement sent to Adam Porter <adam@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#32503; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 23 Aug 2018 01:45:02 UTC

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