GNU bug report logs - #51412
29.0.50; cl--mapcar-many fails inconsistently in the presence of circular lists; other shortcomings

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: akater <nuclearspace@HIDDEN>; dated Tue, 26 Oct 2021 12:02:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

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


Received: (at 51412) by debbugs.gnu.org; 14 Sep 2022 18:38:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 14 14:38:59 2022
Received: from localhost ([127.0.0.1]:56228 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oYXHn-0006na-9n
	for submit <at> debbugs.gnu.org; Wed, 14 Sep 2022 14:38:59 -0400
Received: from quimby.gnus.org ([95.216.78.240]:52874)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1oYXHm-0006nN-3j
 for 51412 <at> debbugs.gnu.org; Wed, 14 Sep 2022 14:38:58 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID
 :Date:References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To: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=+lPJPWs0uHv0GpbpTCg1Uicw+u4BC7ulVKt/J6c7h6o=; b=PeioOPLcKurqeCOZtC97kw1BhN
 tuZTAkthEH7zqLpJu6yJ+DS0wa/DWnZq2757MsHP3q9mMHQHGnbaatQcd4w7vY3wVhrMI7ln4hsng
 2ZVzOi1Ep0gpERjXwfawbxwFyD80zwG+lh7s8LBaopkfj7NnCi2tndK2VmuxqRiCzwLw=;
Received: from [84.212.220.105] (helo=joga)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1oYXHc-0001VC-33; Wed, 14 Sep 2022 20:38:50 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: akater <nuclearspace@HIDDEN>
Subject: Re: bug#51412: 29.0.50; cl--mapcar-many fails inconsistently in the
 presence of circular lists; other shortcomings
In-Reply-To: <87ee88dmzb.fsf@HIDDEN> (akater's message of "Tue, 26 Oct 2021
 11:50:00 +0000")
References: <87ee88dmzb.fsf@HIDDEN>
X-Now-Playing: Scout Niblett's _Uptown Top Ranking_: "Dare!"
Date: Wed, 14 Sep 2022 20:38:45 +0200
Message-ID: <87leql3ioa.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview:  akater <nuclearspace@HIDDEN> writes: > cl--mapcar-many
 is used as a backend for implementing several cl- > functions in cl-extra.
 To deal with arbitrary number of arguments > (passed to cl--mapcar-many as
 list cl-seq), it goes through th [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 51412
Cc: 51412 <at> debbugs.gnu.org, Stefan Monnier <monnier@HIDDEN>
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: -3.3 (---)

akater <nuclearspace@HIDDEN> writes:

> cl--mapcar-many is used as a backend for implementing several cl-
> functions in cl-extra.  To deal with arbitrary number of arguments
> (passed to cl--mapcar-many as list cl-seq), it goes through them all
> whenever there are more than 2, in advance, and attempts to compute the
> minimal length.
>
> This fails if any of the arguments is a circular list.
>
> To reproduce, just evaluate (cl-map 'list #'identity '#1=3D(a . #1#) nil =
nil).

Debugger entered--Lisp error: (circular-list (a . #2))

> Note that (cl-map 'list #'identity '#1=3D(a . #1#) nil) doesn't fail so
> this is at the very least inconsistent.  N.B.: CL spec says =E2=80=9CShou=
ld be
> prepared to signal an error=E2=80=9D for improper lists for such function=
s.
> Long story short, this means circular lists can be supported by CL
> implementations according to CL spec.

It's inconsistent, so that should probably be fixed.  But isn't
signalling an error here the right thing to do?  But I guess as long as
not all the lists are circular, then it's fine to return something
here...

Perhaps Stafan has some comments; added to the CCs.




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

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


Received: (at submit) by debbugs.gnu.org; 26 Oct 2021 12:01:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Oct 26 08:01:57 2021
Received: from localhost ([127.0.0.1]:45317 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mfL9Q-0005BV-TN
	for submit <at> debbugs.gnu.org; Tue, 26 Oct 2021 08:01:57 -0400
Received: from lists.gnu.org ([209.51.188.17]:33848)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <nuclearspace@HIDDEN>) id 1mfL9P-0005BO-OR
 for submit <at> debbugs.gnu.org; Tue, 26 Oct 2021 08:01:56 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:44168)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <nuclearspace@HIDDEN>)
 id 1mfL9M-0007VB-ER
 for bug-gnu-emacs@HIDDEN; Tue, 26 Oct 2021 08:01:55 -0400
Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]:38739)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <nuclearspace@HIDDEN>)
 id 1mfL9H-0001M6-0w
 for bug-gnu-emacs@HIDDEN; Tue, 26 Oct 2021 08:01:52 -0400
Received: by mail-ed1-x52d.google.com with SMTP id r4so12621940edi.5
 for <bug-gnu-emacs@HIDDEN>; Tue, 26 Oct 2021 05:01:46 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:subject:date:message-id:mime-version
 :content-transfer-encoding;
 bh=k4LkBQQBcmQ/oLrAxv2mnvaSkiWuzopAviPVfPW4ays=;
 b=GBNGDBSUhs8EWHAOwbAtXntHgI4BjfTGRJPWkCalV2tmEx3xrP3bLTUw0/aq9yf0A7
 l3IsRurFF7gL8iACj+aiHI3M2E3D9VYbwo+55lo2AnBULUZXNzwYNnyYPV/kDi3+bxxl
 SnCHSOunku6z9h34gDDuZ53NhPIIVmShOfONtYCtQ8ZZwW0xJ2zk6yU9D0rTf7AlCea1
 vc6JW3yghNFrWcysedq+JJM6rh0lw5p2mI45eWZ6qUg3xuVF0dWVpjFkdqnN7/xmuTr/
 co1r48HUMap3U0AiHJhnRpcL4htxo1Obrff5d82DQfnnHa4jGIBzaxlNJ99xGSPBY4IX
 hAkA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:subject:date:message-id:mime-version
 :content-transfer-encoding;
 bh=k4LkBQQBcmQ/oLrAxv2mnvaSkiWuzopAviPVfPW4ays=;
 b=1PSKqrmFLeak3dTv8k7wu0zZFqMKv0N25CpA2NF6/UvOFIKGMw2wiHzwZCI+WVLtKP
 T0/ke1QjGZtXRf43/mjZHNiS76/epEm5wK6X8Cb10NddgAvq9JgLY0LkdNajtcPqx+mP
 aiRqoLY4ceTeqNXvKUSeUTZvZ9S2QUxM5EV71+YC1ic0GQPC5HpjXUqIasM9PwZ2QI+C
 n6q5KlLnI5ka2uw5+yxRMGg+2rYm53JrOjrI6mir73qarukLWXXZdhdbwKxQzxLfOC01
 3OOIaEW31SKkncOJSOQjydy3AqvfO9Mi7SU8h9zqgo31VjRf/I06jb/P2p2m1QT/FZJf
 z00w==
X-Gm-Message-State: AOAM532Oe0gs9Wwh6kwxUDu4smk0sdcdbFHqgRm8dHMVtL7D+H7tEK67
 V1xSX1rWcwkrREFulGjd1/lv7sFoHHw=
X-Google-Smtp-Source: ABdhPJzV949VTyC2t5MX3/3juod4OOFRjpemP6FxmoAmsq1tedR3Dcln1Al2iz25CqaY+4xZ8UPpgg==
X-Received: by 2002:a17:906:a14a:: with SMTP id
 bu10mr28615110ejb.540.1635249696418; 
 Tue, 26 Oct 2021 05:01:36 -0700 (PDT)
Received: from localhost ([185.31.175.226])
 by smtp.googlemail.com with ESMTPSA id e6sm4557066ejs.112.2021.10.26.05.01.35
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 26 Oct 2021 05:01:36 -0700 (PDT)
From: akater <nuclearspace@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 29.0.50; cl--mapcar-many fails inconsistently in the presence of
 circular lists; other shortcomings
Date: Tue, 26 Oct 2021 11:50:00 +0000
Message-ID: <87ee88dmzb.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass client-ip=2a00:1450:4864:20::52d;
 envelope-from=nuclearspace@HIDDEN; helo=mail-ed1-x52d.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
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: -2.3 (--)

cl--mapcar-many is used as a backend for implementing several cl-
functions in cl-extra.  To deal with arbitrary number of arguments
(passed to cl--mapcar-many as list cl-seq), it goes through them all
whenever there are more than 2, in advance, and attempts to compute the
minimal length.

This fails if any of the arguments is a circular list.

To reproduce, just evaluate (cl-map 'list #'identity '#1=3D(a . #1#) nil ni=
l).

Note that (cl-map 'list #'identity '#1=3D(a . #1#) nil) doesn't fail so
this is at the very least inconsistent.  N.B.: CL spec says =E2=80=9CShould=
 be
prepared to signal an error=E2=80=9D for improper lists for such functions.
Long story short, this means circular lists can be supported by CL
implementations according to CL spec.

Other shortcomings: going through all sequences in advance is very
inefficient.  mapcar-many also checks sequence types at runtime even
though they are known in advance which is also wasteful.

The mechanism used in recent suggested implementation of cl-map-into
https://lists.gnu.org/archive/html/emacs-devel/2021-10/msg00636.html
could be used to reimplement other sequence-oriented cl-extra functions
and resolve these issues, if it's merged.

I wrote some supporting macros there with a view towards this use; this
bug report is partially an apology for them.




Acknowledgement sent to akater <nuclearspace@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#51412; 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: Wed, 14 Sep 2022 18:45:01 UTC

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