From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#58601: 29.0.50; Infinite loop in byte-compile--first-symbol-with-pos Date: Tue, 18 Oct 2022 19:34:08 +0300 Message-ID: <87pmepw0ov.fsf@tcd.ie> References: <8735bm6nl9.fsf@tcd.ie> Reply-To: "Basil L. Contovounesios" Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35679"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , 58601@debbugs.gnu.org, Stefan Monnier To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 18 18:38:10 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 1okpbU-00095t-F0 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 18 Oct 2022 18:38:08 +0200 Original-Received: from localhost ([::1]:50876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okpbT-0003sp-2o for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 18 Oct 2022 12:38:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okpYV-0003hS-Iv for bug-gnu-emacs@gnu.org; Tue, 18 Oct 2022 12:35:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54905) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1okpYU-00022V-4r for bug-gnu-emacs@gnu.org; Tue, 18 Oct 2022 12:35:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1okpYT-0005uP-NG for bug-gnu-emacs@gnu.org; Tue, 18 Oct 2022 12:35:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 18 Oct 2022 16:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58601 X-GNU-PR-Package: emacs Original-Received: via spool by 58601-submit@debbugs.gnu.org id=B58601.166611085722632 (code B ref 58601); Tue, 18 Oct 2022 16:35:01 +0000 Original-Received: (at 58601) by debbugs.gnu.org; 18 Oct 2022 16:34:17 +0000 Original-Received: from localhost ([127.0.0.1]:53981 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1okpXl-0005sx-At for submit@debbugs.gnu.org; Tue, 18 Oct 2022 12:34:17 -0400 Original-Received: from mail-ej1-f48.google.com ([209.85.218.48]:39878) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1okpXj-0005sk-Ud for 58601@debbugs.gnu.org; Tue, 18 Oct 2022 12:34:16 -0400 Original-Received: by mail-ej1-f48.google.com with SMTP id b2so33652228eja.6 for <58601@debbugs.gnu.org>; Tue, 18 Oct 2022 09:34:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=ivB/Oi54TPTynY8ZNZDst5WLgaloK3SaZ0QleG8Gy1k=; b=gn32YPRKDk6cgczx62K8iDcK5EeyRsCq6UZPmJqu+U+QoJgnJgjFGK3R+ANGrqEAAb 82oPeBFLT5EyEI6/MqDrJ4dBWPMeSnKVQprBdms10cNJEmJxmvwmZ94LmSeov1yUbNuj ha7/10vbF5/QP/cZWgzJB9PqJYzbzqnhylGjPBVw9DnCKaBFGQoKDN3tGh1IRWL8rk/Q 0PturL6zSxkCeITPtcHYk1n57AtfOTq0PG0/sAjYgwEop3rB2PAGnvg5LRsF3ma7CH5F 0KA35glzvuubVfwfcBtvlsqSrBiVmxaGtn1i1TUPY5AsLu2vAc1IUj9U2Xf3AlRhQK91 amaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ivB/Oi54TPTynY8ZNZDst5WLgaloK3SaZ0QleG8Gy1k=; b=2iMJId4rl4zt6y70iJvu91dFUACj4E4DzHrhGX1HNGsp/PP8Sd9YEtDeZ7XLxuI/kH 8fMsde1YZZ6cbLNNQzK36K+cgidjxvGdzLRnemjI0L9kX7gCm6NxXI1D6MvPgw3/Z5IZ hJfqpuRs8AfF1oOTUzO+w1h8Evn0U3miCHeNL2e6xpkbpBcHiFvP1OUZhwHgwBUBGihz +jsNcLsbbYPU0zH2Wjt1PEOfvhdXUzGDqph/f7MSEKdoPr0YSFICQilMdGeIm2ba+XH9 nQcdn0oScQZN8bl+EyTY4D7MFytuULEKsC8rb0jqLFWeeqTbJWxrPZ8CjLZG1dLCL21Z 69RQ== X-Gm-Message-State: ACrzQf2A9H9aoVvzvhV+0rCOSQI6bzrg7d19vSpOVJFDiPSxhnV6k8+F biOOic6N9u/7IQgi9sEHMuNyEA== X-Google-Smtp-Source: AMsMyM6Yg1XwVX5XwvpnQWI78d80ujOvsFBHhIMCwoFAkJ1tcqkDaC118/qgOcX0kAI5I7kq/nXldA== X-Received: by 2002:a17:907:2c6a:b0:78d:caaa:27a8 with SMTP id ib10-20020a1709072c6a00b0078dcaaa27a8mr3216056ejc.79.1666110850177; Tue, 18 Oct 2022 09:34:10 -0700 (PDT) Original-Received: from localhost ([2a02:587:321f:7e8a:d9:365a:ced1:b3d1]) by smtp.gmail.com with ESMTPSA id jt3-20020a170906dfc300b0078db5bddd9csm7786587ejc.22.2022.10.18.09.34.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Oct 2022 09:34:09 -0700 (PDT) In-Reply-To: (Alan Mackenzie's message of "Tue, 18 Oct 2022 15:01:49 +0000") 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:245811 Archived-At: Alan Mackenzie [2022-10-18 15:01 +0000] wrote: > On Tue, Oct 18, 2022 at 02:24:02 +0300, Basil L. Contovounesios wrote: > >> I.e. the 'pure' compile-time form has a cycle, and the DFS of >> byte-compile--first-symbol-with-pos gets lost. > > What's a DFS? Depth-First Search. >> Paraphrasing Stefan, it's acceptable if the compiler mishandles >> circular source code, but it should be able to handle circular data. > > The problem here seems to be feeding macroexp-warn-and-return with data > as the FORM argument. That's not the problem, because it's just for illustrative purposes. Instead of 'arg' being passed unchanged as the FORM argument, it could just as well have been `(my-frobnicate ,arg). > FORM is intended only to be an executable lisp form. `(my-frobnicate ,arg) fits that bill, right? The end result is the same: macroexp-warn-and-return is fed a form containing a cycle, without any of the code that gives rise to the form being circular itself. >> I don't know why, but I can reproduce the hang only when the form is inside >> ert-deftest+should, and not inside a plain defun. > > There is a huge concentration of "advanced" features inside those ~20 > lines of Lisp code. Maybe when the compiler detects sufficiently advanced Lisp it should (signal 'indistinguishable-from-magic (list form)) > There's eval-and-compile, That's just a shortcut: one could equivalently put my-cycle and my-identity in a separate file and 'require' it. The compiler just needs to know that my-cycle is pure and my-identity has a compiler-macro before reaching their call sites. > nconc, a compiler-macro, and ert. ;-) You forgot 'pure'. We're spoilt for choice! >> Perhaps byte-compile--first-symbol-with-pos needs to employ something >> like byte-run--ssp-seen? Or does ERT somehow come into play? > > It wouldn't be difficult, just tedious, to add checking for circular > lists into byte-compile--first-symbol-with-pos. But a circular list is > an invalid argument for FORM in macorexp-warn-and-return, see above. How else should a compiler-macro safely warn about a problematic function argument? > There are surely lots of places in Emacs where feeding a circular list as > an argument to a function will cause a hang. Sure, but a subset of those places should reasonably be expected to not hang... > At the moment, I'm not in favour of doing anything here. I don't think > there's a bug. ...for instance, when dealing with compile-time constants in real-world Elisp. Thanks, -- Basil