Subject: bug#58601: 29.0.50; Infinite loop in byte-compile--first-symbol-with-pos

From: Stefan Monnier <[email-masked]>
Date: Wed, 19 Oct 2022 08:48:27 -0400

>> where `somefun` does *not* come from the source but from the
>> compiler-macro instead and hence doesn't have any sympos, and then
>> `somearg1` was an expression of the form
>
>>    (quote #1=(1 2 3 . #1#))
>
>> So, there was no cycle in the code part, the cycle is only inside the
>> data embedded in the code.
>
> I think somebody who writes something like that _deserves_ to go into an
> infinite loop.

Circular data is not very frequent, but it's not rare either (as you
found out during the development of sympos, as evidenced by
`byte-run--ssp-seen`).

`byte-compile--first-symbol-with-pos` didn't bump into it until now
simply because it usually gets "lucky" and finds a sympos before getting
to a cyclic embedded data.

> Have you ever seen anything at all like this in real life?

Of course, and so have you :-)

> You have fixed this "problem" by arbitrarily limiting the size of
> valid form stacks that can be searched, and the depth to which they
> can be searched.  This limit, 10, seems too small.  There can easily
> be form stacks with more than 10 elements.  Do you have any objection
> if I change that 10 to something closer to infinity?

Be my guest.

> Something which will encompass any form stack likely to be
> encountered in practice?  I would suggest the number 300.

Fine by me.  Tho once we get into this range, 666 sounds a lot
more enticing. :-)

        Stefan