From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#58472: [PATCH] Make `message-unique-id' less prone to collisions Date: Wed, 12 Oct 2022 11:08:12 -0700 Organization: UCLA Computer Science Department Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33922"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Cc: 58472@debbugs.gnu.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 12 20:09:14 2022 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 1oigAK-0008bG-OH for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 12 Oct 2022 20:09:13 +0200 Original-Received: from localhost ([::1]:41430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oigAJ-0004ul-IM for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 12 Oct 2022 14:09:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oigAB-0004uV-1S for bug-gnu-emacs@gnu.org; Wed, 12 Oct 2022 14:09:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59323) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oigAA-0008Lt-Oe for bug-gnu-emacs@gnu.org; Wed, 12 Oct 2022 14:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oigAA-0004uJ-IU for bug-gnu-emacs@gnu.org; Wed, 12 Oct 2022 14:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 12 Oct 2022 18:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58472 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 58472-submit@debbugs.gnu.org id=B58472.166559811318808 (code B ref 58472); Wed, 12 Oct 2022 18:09:02 +0000 Original-Received: (at 58472) by debbugs.gnu.org; 12 Oct 2022 18:08:33 +0000 Original-Received: from localhost ([127.0.0.1]:58397 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oig9d-0004tE-9W for submit@debbugs.gnu.org; Wed, 12 Oct 2022 14:08:33 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:53170) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oig9U-0004st-Ed for 58472@debbugs.gnu.org; Wed, 12 Oct 2022 14:08:27 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 27AE0160080; Wed, 12 Oct 2022 11:08:14 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 5UrYbjE3Q3Oy; Wed, 12 Oct 2022 11:08:13 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 5E20E160084; Wed, 12 Oct 2022 11:08:13 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.9.2 zimbra.cs.ucla.edu 5E20E160084 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu; s=78364E5A-2AF3-11ED-87FA-8298ECA2D365; t=1665598093; bh=bShjGuKQITgPB26PHpPpazoSmPnaO+hlMVFvhkV4nCw=; h=Message-ID:Date:MIME-Version:To:From:Subject:Content-Type: Content-Transfer-Encoding; b=Z2kCngL5o9QiR+4pZYOp7+w4ewEtCAKGL/57/RVx3OUqhmTC59ONIbDtEmJ5nlV5w zLVU4DAFn6HMu/A25IAUxDjMp7KbM4DeCaqCdIovEAIg9sFbndrakj32UznboPOou7 6beeSN5O4FibOrLAMdwDbD/Ozw7dQqoXNW/1/8XM= X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id aK7EmPoaEzDz; Wed, 12 Oct 2022 11:08:13 -0700 (PDT) Original-Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 35C0A160080; Wed, 12 Oct 2022 11:08:13 -0700 (PDT) Content-Language: en-US In-Reply-To: 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:245242 Archived-At: On 2022-10-12 09:07, Stefan Kangas wrote: > This seems > unnecessary now that, AFAIU, `time-convert' can do that for us portably > (please correct me if I'm wrong, Paul). > > I suggest that we instead base the left-hand side of the Message-ID on: > > 1. (time-convert nil (expt 10 9)) > 2. 2^N bits of pseudo random data (e.g. N=32) (time-convert nil t) would be a bit more efficient. If the goal is to avoid collisions, though, wouldn't it be better to avoid the time entirely? time is not very random in the high order bits. Also, the comment about ".fsf" and other newsreaders is wrong. If we're generating IDs at random it doesn't matter whether we append ".fsf" as the ".fsf" itself could be randomly generated by another newsreader. The ".fsf" is just a comment or advertisement or debugging aid or what have you. And if we're changing the algorithm perhaps we should change ".fsf" to something else. Something like this, perhaps, where you can choose LEN as you like: (concat (let ((len 18)) ;; Pass LEN, not -1, to message-number-base36 so that it never ;; returns "" which would make the message-ID nonconforming. (message-number-base36 (random (expt 36 len)) len)) ;; Append ".gnu" to advertise that we're GNU Emacs. ".gnu")