GNU bug report logs - #46906
28.0.50; byte compiler infloops trying to compile infloop

Previous Next

Package: emacs;

Reported by: Pip Cet <pipcet <at> gmail.com>

Date: Wed, 3 Mar 2021 21:15:01 UTC

Severity: normal

Found in version 28.0.50

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 46906 in the body.
You can then email your comments to 46906 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#46906; Package emacs. (Wed, 03 Mar 2021 21:15:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Pip Cet <pipcet <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 03 Mar 2021 21:15:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Pip Cet <pipcet <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; byte compiler infloops trying to compile infloop
Date: Wed, 3 Mar 2021 21:14:18 +0000
Recipe in emacs -Q:

In *scratch*, evaluate:

(byte-compile (lambda (x)
                (if x (f))
                (while t)))

Expected result:

A (fairly useless) bytecode object

Actual result:

A spinning hourglass.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46906; Package emacs. (Wed, 03 Mar 2021 21:45:02 GMT) Full text and rfc822 format available.

Message #8 received at 46906 <at> debbugs.gnu.org (full text, mbox):

From: Pip Cet <pipcet <at> gmail.com>
To: 46906 <at> debbugs.gnu.org
Subject: Re: bug#46906: 28.0.50;
 byte compiler infloops trying to compile infloop
Date: Wed, 3 Mar 2021 21:44:02 +0000
[Message part 1 (text/plain, inline)]
On Wed, Mar 3, 2021 at 9:15 PM Pip Cet <pipcet <at> gmail.com> wrote:
>
> Recipe in emacs -Q:
>
> In *scratch*, evaluate:
>
> (byte-compile (lambda (x)
>                 (if x (f))
>                 (while t)))
>
> Expected result:
>
> A (fairly useless) bytecode object
>
> Actual result:
>
> A spinning hourglass.

Seems to be a fairly obvious bug in byte-opt.el, patch attached.

Okay to commit?

Pip
[0001-Fix-bytecompiler-infloop-compiling-infloops-bug-4690.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46906; Package emacs. (Wed, 03 Mar 2021 23:34:01 GMT) Full text and rfc822 format available.

Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andy Moreton <andrewjmoreton <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#46906: 28.0.50;
 byte compiler infloops trying to compile infloop
Date: Wed, 03 Mar 2021 23:33:16 +0000
On Wed 03 Mar 2021, Pip Cet wrote:

> On Wed, Mar 3, 2021 at 9:15 PM Pip Cet <pipcet <at> gmail.com> wrote:
>>
>> Recipe in emacs -Q:
>>
>> In *scratch*, evaluate:
>>
>> (byte-compile (lambda (x)
>>                 (if x (f))
>>                 (while t)))
>>
>> Expected result:
>>
>> A (fairly useless) bytecode object
>>
>> Actual result:
>>
>> A spinning hourglass.
>
> Seems to be a fairly obvious bug in byte-opt.el, patch attached.

Perhaps add your reproducer as a test case ?

    AndyM





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46906; Package emacs. (Thu, 04 Mar 2021 07:19:02 GMT) Full text and rfc822 format available.

Message #14 received at 46906 <at> debbugs.gnu.org (full text, mbox):

From: Pip Cet <pipcet <at> gmail.com>
To: Andy Moreton <andrewjmoreton <at> gmail.com>
Cc: 46906 <at> debbugs.gnu.org
Subject: Re: bug#46906: 28.0.50;
 byte compiler infloops trying to compile infloop
Date: Thu, 4 Mar 2021 07:17:54 +0000
[Message part 1 (text/plain, inline)]
On Wed, Mar 3, 2021 at 11:34 PM Andy Moreton <andrewjmoreton <at> gmail.com> wrote:
> On Wed 03 Mar 2021, Pip Cet wrote:
> > On Wed, Mar 3, 2021 at 9:15 PM Pip Cet <pipcet <at> gmail.com> wrote:
> >>
> >> Recipe in emacs -Q:
> >>
> >> In *scratch*, evaluate:
> >>
> >> (byte-compile (lambda (x)
> >>                 (if x (f))
> >>                 (while t)))
> >>
> >> Expected result:
> >>
> >> A (fairly useless) bytecode object
> >>
> >> Actual result:
> >>
> >> A spinning hourglass.
> >
> > Seems to be a fairly obvious bug in byte-opt.el, patch attached.
>
> Perhaps add your reproducer as a test case ?

Absolutely, thanks for the suggestion. See attached patch.

Should there, maybe, be a tag for tests that are known to loop forever
when they fail? It feels weird to write a test without a single should
in it...

Pip
[0001-Fix-bytecompiler-infloop-compiling-infloops-bug-4690.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46906; Package emacs. (Thu, 04 Mar 2021 10:17:03 GMT) Full text and rfc822 format available.

Message #17 received at 46906 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Pip Cet <pipcet <at> gmail.com>
Cc: Andy Moreton <andrewjmoreton <at> gmail.com>, 46906 <at> debbugs.gnu.org
Subject: Re: bug#46906: 28.0.50; byte compiler infloops trying to compile
 infloop
Date: Thu, 04 Mar 2021 11:15:49 +0200
>> Perhaps add your reproducer as a test case ?
>
> Absolutely, thanks for the suggestion. See attached patch.
>
> Should there, maybe, be a tag for tests that are known to loop forever
> when they fail? It feels weird to write a test without a single should
> in it...

Maybe 'with-timeout' could help not to loop forever in tests?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46906; Package emacs. (Thu, 04 Mar 2021 10:20:02 GMT) Full text and rfc822 format available.

Message #20 received at 46906 <at> debbugs.gnu.org (full text, mbox):

From: Pip Cet <pipcet <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: Andy Moreton <andrewjmoreton <at> gmail.com>, 46906 <at> debbugs.gnu.org
Subject: Re: bug#46906: 28.0.50;
 byte compiler infloops trying to compile infloop
Date: Thu, 4 Mar 2021 10:19:18 +0000
On Thu, Mar 4, 2021 at 10:16 AM Juri Linkov <juri <at> linkov.net> wrote:
> Maybe 'with-timeout' could help not to loop forever in tests?

I don't think so, because it doesn't work for Lisp infloops.
(with-timeout (1 (error "foo")) (while t)) doesn't work here, at
least.

Pip




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46906; Package emacs. (Thu, 04 Mar 2021 11:17:02 GMT) Full text and rfc822 format available.

Message #23 received at 46906 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Pip Cet <pipcet <at> gmail.com>
Cc: Andy Moreton <andrewjmoreton <at> gmail.com>, 46906 <at> debbugs.gnu.org,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#46906: 28.0.50; byte compiler infloops trying to compile
 infloop
Date: Thu, 04 Mar 2021 12:16:12 +0100
Pip Cet <pipcet <at> gmail.com> writes:

> I don't think so, because it doesn't work for Lisp infloops.
> (with-timeout (1 (error "foo")) (while t)) doesn't work here, at
> least.

Yes, you need to put something that yields in there for `with-timeout'
to work.  For instance:

(with-timeout (1 (error "foo")) (while t (sleep-for 0.1)))

However, I haven't checked whether this form triggers the bug that we're
trying to reproduce.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46906; Package emacs. (Thu, 04 Mar 2021 12:16:02 GMT) Full text and rfc822 format available.

Message #26 received at 46906 <at> debbugs.gnu.org (full text, mbox):

From: Pip Cet <pipcet <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Andy Moreton <andrewjmoreton <at> gmail.com>, 46906 <at> debbugs.gnu.org,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#46906: 28.0.50;
 byte compiler infloops trying to compile infloop
Date: Thu, 4 Mar 2021 12:15:17 +0000
On Thu, Mar 4, 2021 at 11:16 AM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:
> Pip Cet <pipcet <at> gmail.com> writes:
> > I don't think so, because it doesn't work for Lisp infloops.
> > (with-timeout (1 (error "foo")) (while t)) doesn't work here, at
> > least.
>
> Yes, you need to put something that yields in there for `with-timeout'
> to work.  For instance:
>
> (with-timeout (1 (error "foo")) (while t (sleep-for 0.1)))
>
> However, I haven't checked whether this form triggers the bug that we're
> trying to reproduce.

Even if it would, that wouldn't solve our issue: it's the optimizer
which infloops trying to compile the form, and the optimizer certainly
does not yield anywhere that I'm aware of...

I think we're just going to have to put in a test which, on systems
with the bug, loops indefinitely. We could make it "expensive", though
it isn't, really.

(I'm not sure how many people are trying to run the Emacs 28 testsuite
against Emacs 27, or anything like that. It might be a non-issue.)

Pip




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46906; Package emacs. (Thu, 04 Mar 2021 18:45:02 GMT) Full text and rfc822 format available.

Message #29 received at 46906 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Pip Cet <pipcet <at> gmail.com>
Cc: Andy Moreton <andrewjmoreton <at> gmail.com>, 46906 <at> debbugs.gnu.org
Subject: Re: bug#46906: 28.0.50; byte compiler infloops trying to compile
 infloop
Date: Thu, 04 Mar 2021 19:58:30 +0200
> On Thu, Mar 4, 2021 at 10:16 AM Juri Linkov <juri <at> linkov.net> wrote:
>> Maybe 'with-timeout' could help not to loop forever in tests?
>
> I don't think so, because it doesn't work for Lisp infloops.
> (with-timeout (1 (error "foo")) (while t)) doesn't work here, at
> least.

Then maybe run a possibly infinite loop in a separate thread?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46906; Package emacs. (Thu, 04 Mar 2021 18:52:02 GMT) Full text and rfc822 format available.

Message #32 received at 46906 <at> debbugs.gnu.org (full text, mbox):

From: Pip Cet <pipcet <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: Andy Moreton <andrewjmoreton <at> gmail.com>, 46906 <at> debbugs.gnu.org
Subject: Re: bug#46906: 28.0.50;
 byte compiler infloops trying to compile infloop
Date: Thu, 4 Mar 2021 18:50:49 +0000
On Thu, Mar 4, 2021 at 6:44 PM Juri Linkov <juri <at> linkov.net> wrote:
> > On Thu, Mar 4, 2021 at 10:16 AM Juri Linkov <juri <at> linkov.net> wrote:
> >> Maybe 'with-timeout' could help not to loop forever in tests?
> >
> > I don't think so, because it doesn't work for Lisp infloops.
> > (with-timeout (1 (error "foo")) (while t)) doesn't work here, at
> > least.
>
> Then maybe run a possibly infinite loop in a separate thread?

Or even as a separate process, maybe. That's what I'd like to do for
(apply nil)...

Pip




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46906; Package emacs. (Fri, 05 Mar 2021 13:17:02 GMT) Full text and rfc822 format available.

Message #35 received at 46906 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Pip Cet <pipcet <at> gmail.com>
Cc: Andy Moreton <andrewjmoreton <at> gmail.com>, 46906 <at> debbugs.gnu.org,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#46906: 28.0.50; byte compiler infloops trying to compile
 infloop
Date: Fri, 05 Mar 2021 14:16:04 +0100
Pip Cet <pipcet <at> gmail.com> writes:

> I think we're just going to have to put in a test which, on systems
> with the bug, loops indefinitely. We could make it "expensive", though
> it isn't, really.
>
> (I'm not sure how many people are trying to run the Emacs 28 testsuite
> against Emacs 27, or anything like that. It might be a non-issue.)

It's probably not an issue in practice, but it does seem rather
unsatisfactory that we don't have a mechanism for doing tests for
infloops in general.

I wonder whether we could cobble up something just for ert.  For
instance... doing a
(start-process ... "sleep 1; kill -s SIGUSR1 $EMACS_PID") or similar,
and then hook the SIGUSR1 handler to...  er...  do something useful
here.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46906; Package emacs. (Fri, 05 Mar 2021 13:18:01 GMT) Full text and rfc822 format available.

Message #38 received at 46906 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: Andy Moreton <andrewjmoreton <at> gmail.com>, 46906 <at> debbugs.gnu.org,
 Pip Cet <pipcet <at> gmail.com>
Subject: Re: bug#46906: 28.0.50; byte compiler infloops trying to compile
 infloop
Date: Fri, 05 Mar 2021 14:17:00 +0100
Juri Linkov <juri <at> linkov.net> writes:

>> I don't think so, because it doesn't work for Lisp infloops.
>> (with-timeout (1 (error "foo")) (while t)) doesn't work here, at
>> least.
>
> Then maybe run a possibly infinite loop in a separate thread?

I don't think that would work -- our threading stuff is based on
"cooperative multithreading", I think?  Which means that the code we're
testing has to call `yield', which it normally doesn't.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46906; Package emacs. (Mon, 20 Jun 2022 00:02:01 GMT) Full text and rfc822 format available.

Message #41 received at 46906 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: Andy Moreton <andrewjmoreton <at> gmail.com>, Pip Cet <pipcet <at> gmail.com>,
 46906 <at> debbugs.gnu.org
Subject: Re: bug#46906: 28.0.50; byte compiler infloops trying to compile
 infloop
Date: Mon, 20 Jun 2022 02:00:57 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> I don't think that would work -- our threading stuff is based on
> "cooperative multithreading", I think?  Which means that the code we're
> testing has to call `yield', which it normally doesn't.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

We apparently forgot to apply Pip's fix because we started talking about
fixing the test harness.  So I've now applied the fix, but not the test,
because we don't really have a good way to test infinite loops in ert.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 29.1, send any further explanations to 46906 <at> debbugs.gnu.org and Pip Cet <pipcet <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 20 Jun 2022 00:02:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 18 Jul 2022 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 283 days ago.

Previous Next


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