unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Basil L. Contovounesios" via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Alan Mackenzie <acm@muc.de>
Cc: "Mattias Engdegård" <mattiase@acm.org>,
	58601@debbugs.gnu.org,
	"Stefan Monnier" <monnier@iro.umontreal.ca>
Subject: bug#58601: 29.0.50; Infinite loop in byte-compile--first-symbol-with-pos
Date: Fri, 21 Oct 2022 13:47:21 +0300	[thread overview]
Message-ID: <8735bhtpvq.fsf@tcd.ie> (raw)
In-Reply-To: <Y07dM9Yk2LMunhT7@ACM> (Alan Mackenzie's message of "Tue, 18 Oct 2022 17:06:59 +0000")

[-- Attachment #1: Type: text/plain, Size: 852 bytes --]

Alan Mackenzie [2022-10-18 17:06 +0000] wrote:
> On Tue, Oct 18, 2022 at 19:34:08 +0300, Basil L. Contovounesios wrote:
>> Alan Mackenzie [2022-10-18 15:01 +0000] wrote:
>> > 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).
>
> That would not loop, since there is a symbol with position there.
>
>> > 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.
>
> This would not loop.

And yet:


[-- Attachment #2: my.el --]
[-- Type: application/emacs-lisp, Size: 330 bytes --]

[-- Attachment #3: my-tests.el --]
[-- Type: application/emacs-lisp, Size: 165 bytes --]

[-- Attachment #4: Type: text/plain, Size: 2342 bytes --]


Followed by:

  emacs -Q -L . -batch -f batch-byte-compile my.el
  emacs -Q -L . -batch -f batch-byte-compile my-tests.el

The latter hangs prior to Stefan's limit on recursion.

>> >> 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?
>
> by calling the normal byte compiler warning facilities.

Could you please point me to them?

> If there is a symbol somewhere in the FORM passed to them, it won't
> loop, even if it is a circular list.

See the case of my-identity above.

> You called macroexp-warn-and-return from outside of the byte compiler.
> From within the byte compiler, it cannot generate a loop (see above).

What counts as outside of the byte compiler?  Do you mean that
macroexp-warn-and-return should be disallowed in declare forms or macro
definitions?  Or that a compiler-macro should not pass forms derived
from the function's arguments to macroexp-warn-and-return?  AFAIA there
is no precedent for such a restriction, and in fact I see the opposite
trend in recent history:

https://git.sv.gnu.org/cgit/emacs.git/commit/?id=d52c929e31
https://git.sv.gnu.org/cgit/emacs.git/commit/?id=52d5771e0a
https://git.sv.gnu.org/cgit/emacs.git/commit/?id=5ee4209f30
https://git.sv.gnu.org/cgit/emacs.git/commit/?id=96926fa6eb
https://git.sv.gnu.org/cgit/emacs.git/commit/?id=fffa53ff1a
https://git.sv.gnu.org/cgit/emacs.git/commit/?id=bd40ec5d57
https://git.sv.gnu.org/cgit/emacs.git/commit/?id=13d6e8fa54
https://git.sv.gnu.org/cgit/emacs.git/commit/?id=155ddde4dd

> Maybe you could construct an example of a circular list without a symbol
> from code being compiled.  Maybe you could cause a warning from a correct
> call of macroexp-warn-and-return to loop.  But I'd be surprised.

You have repeatedly asserted that macroexp-warn-and-return will not loop
if used correctly, but it is not clear to me from your description what
correct use of macroexp-warn-and-return entails.  Could you please
explain?

Thanks,

-- 
Basil

      parent reply	other threads:[~2022-10-21 10:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-17 23:24 bug#58601: 29.0.50; Infinite loop in byte-compile--first-symbol-with-pos Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-18 14:51 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-18 16:33   ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-18 19:19     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-18 15:01 ` Alan Mackenzie
2022-10-18 16:18   ` dick
2022-10-18 16:34   ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-18 17:06     ` Alan Mackenzie
2022-10-18 17:39       ` dick
2022-10-18 19:19       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-19  8:52         ` Alan Mackenzie
2022-10-19 12:48           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-21 10:57             ` Mattias Engdegård
2022-10-21 10:47           ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-21 10:47       ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8735bhtpvq.fsf@tcd.ie \
    --to=bug-gnu-emacs@gnu.org \
    --cc=58601@debbugs.gnu.org \
    --cc=acm@muc.de \
    --cc=contovob@tcd.ie \
    --cc=mattiase@acm.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).