GNU bug report logs - #80012
31.0.50; native-comp-async-on-battery-power recursive require problem

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: Sean Whitton <spwhitton@HIDDEN>; dated Mon, 15 Dec 2025 16:10:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

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


Received: (at 80012) by debbugs.gnu.org; 16 Dec 2025 12:14:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Dec 16 07:14:07 2025
Received: from localhost ([127.0.0.1]:53767 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vVTwN-0006tn-FD
	for submit <at> debbugs.gnu.org; Tue, 16 Dec 2025 07:14:07 -0500
Received: from sendmail.purelymail.com ([34.202.193.197]:43984)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <spwhitton@HIDDEN>)
 id 1vVTwK-0006st-OF
 for 80012 <at> debbugs.gnu.org; Tue, 16 Dec 2025 07:14:06 -0500
DKIM-Signature: a=rsa-sha256;
 b=KmVy3uEPbfnWUGaaSpoAzxC/IdpGP1ZbF1b2wTxqUVUpDo+P0WytjBVj7px+tyhtMWzUSf7+zKLE78A3mM1tahTb0XnjK1ZzMA5kjHrWUnNb+yc9tqH+uxw2MmKgrY9wNluuxfS/od6B+YYBHQVYRLc547FHLybUKoPSF5QxVsi8xXe+jM3qS8tdcHlb6Zj6pzKdYLRrFjH/keFer0baSXVz6MPmSl6M3PcsfWIgxTSVd+YguQCQcBvVaPs1ZKm4B28Y0CtG4LHD2wEVOWlm1Q2XPrapFt9j2hphtJZKMZ1J9y84vEUucSwpkaCqxCpjlB+bVJpIlTQvfrrZcRADtg==;
 s=purelymail1; d=spwhitton.name; v=1;
 bh=TIdMyKXOee/c98m0XCMd9ZZiAgqZSvmUp4cUUKgZ2wY=;
 h=Received:Received:From:To:Subject:Date; 
DKIM-Signature: a=rsa-sha256;
 b=hiP7+KTRfNHmAMhMqxFJCXHgi8/vOpQFz6fJUSd9/V6JMx1mp0cBw4Kd8DrCJVdN76/yHWSWkmuP7xzWUM7aEsd61WwNt/ROcBPgmBYLXcPAXC6N6krzoisgC5eHeFRBWejJl1iTRxY9xfpYqa+Qo8ZWRUMXkB0ns1anRDKoR4rSWMKfQvB4jeD7X4KwUAY6h/yB2dbIBGCaMuNKSbvhMvuD5FiXO9YYiV5NpT0LdlQwFwOIirVYqPtD41WFWP5wnusRuu/C5xel4LlyvOx3zrVv69WjUkvGWjfK8Sl2apGc5DW3PBZtm1SEiz1gif71G/liQKbNCpTB4LNL8NqLLQ==;
 s=purelymail1; d=purelymail.com; v=1;
 bh=TIdMyKXOee/c98m0XCMd9ZZiAgqZSvmUp4cUUKgZ2wY=;
 h=Feedback-ID:Received:Received:From:To:Subject:Date; 
Feedback-ID: 20115:3760:null:purelymail
X-Pm-Original-To: 80012 <at> debbugs.gnu.org
Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -1894440593; 
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Tue, 16 Dec 2025 12:13:57 +0000 (UTC)
Received: by zephyr.silentflame.com (Postfix, from userid 1000)
 id 3938794044D; Tue, 16 Dec 2025 12:13:55 +0000 (GMT)
From: Sean Whitton <spwhitton@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#80012: 31.0.50; native-comp-async-on-battery-power
 recursive require problem
In-Reply-To: <jwv4iprp10b.fsf-monnier+emacs@HIDDEN>
References: <878qf3ohgk.fsf@HIDDEN> <86v7i766u6.fsf@HIDDEN>
 <87jyynmx6f.fsf@HIDDEN>
 <jwv4iprp10b.fsf-monnier+emacs@HIDDEN>
Date: Tue, 16 Dec 2025 12:13:55 +0000
Message-ID: <87a4zityik.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 80012
Cc: Eli Zaretskii <eliz@HIDDEN>, 80012 <at> debbugs.gnu.org
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: -1.0 (-)

Hello,

On Mon 15 Dec 2025 at 10:33pm -05, Stefan Monnier wrote:

> I don't think we should make it specific to any package.
> I'm not sure where's the better place to break the recursion, but
> something like the patch below maybe?
> [...]
> Then again, I wonder why the `added-something` didn't break the
> recursion already.  Maybe it's because we load FOO.elc which triggers
> `native--compile-async`, which loads `battery.elc` which triggers
> `native--compile-async` recursively, which again tries to load
> `battery` at which point we get the recursive require error?
> [...]
> But IIRC we only signal a recursive require on the 3rd step of
> the recursion, specifically because it's "common" for a second
> recursive load to be normal and successful, so I'm not sure my
> diagnostic is correct: the
>
>     (if-let* ((entry (seq-find ...
>
> test should prevent the third nesting of `require`s.

Hmm, it seems like we need more information about the sequence of
events.  Do you have any thoughts on where I could insert calls to
'message' and 'backtrace' to try to narrow down the various
possibilities you mention?

-- 
Sean Whitton




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

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


Received: (at 80012) by debbugs.gnu.org; 16 Dec 2025 03:33:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 15 22:33:29 2025
Received: from localhost ([127.0.0.1]:48139 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vVLoX-0006OK-DL
	for submit <at> debbugs.gnu.org; Mon, 15 Dec 2025 22:33:29 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:39052)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1vVLoU-0006Ns-Lg
 for 80012 <at> debbugs.gnu.org; Mon, 15 Dec 2025 22:33:27 -0500
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id C6B4581C24;
 Mon, 15 Dec 2025 22:33:20 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1765855999;
 bh=DeD8hMUUTYw3IEAbYS4wXFbQuyP88Z3lzZYpuweun0g=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=DiDXuTfb5B62OVrg2uI3sqvAkq/uWmXyABf/h6Z+XmxrYS+kSWOzsVo+UgvZj8F+h
 xtxFsg9aE3qr1FeehHoR10SgoM18rf2rwUe2hPI5OgRUT1pEGUn4/GixxdOEl44h7g
 oKR4yJyI9YyZUDJooYEYmdhZN11SPu0WFE6nAmxfCato6zKoqSA5wjDd5z1FmFOyaO
 NW09bLIavvxP1k2ck548g6p+lFMrC8yskJPdE/0nSOU91/mEYpJKRJJWhouPMhkBTc
 N+XleMX4MCHUVnGpc1pAdwH7LBwRaOY1g17LpVtLjS8romh4ZXsfFgq+tra7iB9nJU
 rtY7ZrDkZeQIQ==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id CBADC8071A;
 Mon, 15 Dec 2025 22:33:19 -0500 (EST)
Received: from pastel (104-195-240-239.cpe.teksavvy.com [104.195.240.239])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 987361203AB;
 Mon, 15 Dec 2025 22:33:19 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Sean Whitton <spwhitton@HIDDEN>
Subject: Re: bug#80012: 31.0.50; native-comp-async-on-battery-power
 recursive require problem
In-Reply-To: <87jyynmx6f.fsf@HIDDEN>
Message-ID: <jwv4iprp10b.fsf-monnier+emacs@HIDDEN>
References: <878qf3ohgk.fsf@HIDDEN> <86v7i766u6.fsf@HIDDEN>
 <87jyynmx6f.fsf@HIDDEN>
Date: Mon, 15 Dec 2025 22:33:18 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.129 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 80012
Cc: Eli Zaretskii <eliz@HIDDEN>, 80012 <at> debbugs.gnu.org
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 (---)

>    (and-let* (((not native-comp-async-on-battery-power))
> +             ((not (and load-in-progress
> +                        (equal load-file-name (locate-library "battery")))))
>               ((require 'battery))
> --8<---------------cut here---------------end--------------->8---
>
> or
>
> +             ;; If we are already loading battery.el or dbus.el, just
> +             ;; skip JIT compilation, for now (bug#80012).
> +             ((condition-case e
> +                  (require 'battery)
> +                (recursive-require nil)))
>               battery-status-function

I don't think we should make it specific to any package.
I'm not sure where's the better place to break the recursion, but
something like the patch below maybe?

    diff --git a/lisp/emacs-lisp/comp-run.el b/lisp/emacs-lisp/comp-run.el
    index 5e33b1bc318..fd3fabd4848 100644
    --- a/lisp/emacs-lisp/comp-run.el
    +++ b/lisp/emacs-lisp/comp-run.el
    @@ -418,6 +418,8 @@ comp-subr-trampoline-install
                                       (comp-trampoline-compile subr-name))))
             (comp--install-trampoline subr-name trampoline)))))
     
    +(defvar native--in-compile-async nil)
    +
     ;;;###autoload
     (defun native--compile-async (files &optional recursively load selector)
       ;; BEWARE, this function is also called directly from C.
    @@ -494,9 +496,11 @@ native--compile-async
                                            out-filename)))))))
         ;; Perhaps nothing passed `native--compile-async-skip-p'?
         (when (and added-something
    +               (not native--in-compile-async) ;bug#80012
                    ;; Don't start if there's one already running.
                    (zerop (comp--async-runnings)))
    -      (comp--run-async-workers))))
    +      (let ((native--in-compile-async t))
    +        (comp--run-async-workers)))))
     
     ;;;###autoload
     (defun native-compile-async (files &optional recursively load selector)

Then again, I wonder why the `added-something` didn't break the
recursion already.  Maybe it's because we load FOO.elc which triggers
`native--compile-async`, which loads `battery.elc` which triggers
`native--compile-async` recursively, which again tries to load
`battery` at which point we get the recursive require error?
If so, maybe the patch below is an easier fix.

    diff --git a/lisp/emacs-lisp/comp-run.el b/lisp/emacs-lisp/comp-run.el
    index 5e33b1bc318..da061c5522f 100644
    --- a/lisp/emacs-lisp/comp-run.el
    +++ b/lisp/emacs-lisp/comp-run.el
    @@ -496,7 +498,8 @@ native--compile-async
         (when (and added-something
                    ;; Don't start if there's one already running.
                    (zerop (comp--async-runnings)))
    -      (comp--run-async-workers))))
    +      ;; Don't run it right now because that could inf-loop (bug#80012).
    +      (run-at-time 0 nil #'comp--run-async-workers))))
     
     ;;;###autoload
     (defun native-compile-async (files &optional recursively load selector)


But IIRC we only signal a recursive require on the 3rd step of
the recursion, specifically because it's "common" for a second
recursive load to be normal and successful, so I'm not sure my
diagnostic is correct: the

    (if-let* ((entry (seq-find ...

test should prevent the third nesting of `require`s.


        Stefan





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

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


Received: (at 80012) by debbugs.gnu.org; 15 Dec 2025 20:03:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 15 15:03:36 2025
Received: from localhost ([127.0.0.1]:43734 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vVEn9-0003da-Me
	for submit <at> debbugs.gnu.org; Mon, 15 Dec 2025 15:03:35 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:59066)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1vVEn7-0003dM-Gs
 for 80012 <at> debbugs.gnu.org; Mon, 15 Dec 2025 15:03:34 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1vVEn1-0007mz-Jo; Mon, 15 Dec 2025 15:03:27 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=9gLVPB7ljen2eDTPj6byMhcg5UlCzzWexQyjzCi52DY=; b=Tu9Gi89Sy83G
 oPI+Fut9LFLOGOu/GAze2sTNMyu5p9BIcUt0xqFXwsumcTYiEwcr9q7MplgtFGrt7gRWrfm02oVSU
 8X3h06K5y6Gi1OIGdAfjjmDNgEmlvqc8VRMVfoosvlP1dea6lo0hpIYKFu8Sr5MQ/FR7+lTOThok7
 JtkRiHzmvnRjNQaoiOJlmV52jEbDQ3LOoEIGxslNVfuShTfI/WHktBqvUVpF4xCJthtKz9/ORRJi+
 Q2skdPl6Oa/3IpOsSFb3uTlHhOLLrjuT9OY9mq9Xa/Q4x3d3f1vR51gzhJr7MR2usdgauMmHxkunN
 F0ckOCbc5h0TYjYjanSDHg==;
Date: Mon, 15 Dec 2025 22:03:24 +0200
Message-Id: <86ms3j5x83.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Sean Whitton <spwhitton@HIDDEN>
In-Reply-To: <878qf3mvab.fsf@HIDDEN> (message from Sean
 Whitton on Mon, 15 Dec 2025 18:53:16 +0000)
Subject: Re: bug#80012: 31.0.50; native-comp-async-on-battery-power
 recursive require problem
References: <878qf3ohgk.fsf@HIDDEN> <86v7i766u6.fsf@HIDDEN>
 <87jyynmx6f.fsf@HIDDEN> <86pl8f625j.fsf@HIDDEN>
 <878qf3mvab.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 80012
Cc: acorallo@HIDDEN, monnier@HIDDEN, 80012 <at> debbugs.gnu.org
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 (---)

> From: Sean Whitton <spwhitton@HIDDEN>
> Cc: Andrea Corallo <acorallo@HIDDEN>,  Stefan Monnier
>  <monnier@HIDDEN>,  80012 <at> debbugs.gnu.org
> Date: Mon, 15 Dec 2025 18:53:16 +0000
> 
> >> I prefer the latter.  WDYT?
> >
> > Not sure.  Why do you prefer the latter?
> 
> We're redundantly calling locate-library because require will do the
> same filesystem search right afterwards.

Isn't the file already in load-history by then?

And in any case, I'm not sure that I like the style with catching
errors in this case, since it should be easy to test up front and
avoid the error in the first place, as the first alternative shows.

Just an opinion.




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

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


Received: (at 80012) by debbugs.gnu.org; 15 Dec 2025 18:53:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 15 13:53:27 2025
Received: from localhost ([127.0.0.1]:43103 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vVDhG-0007sl-Is
	for submit <at> debbugs.gnu.org; Mon, 15 Dec 2025 13:53:27 -0500
Received: from sendmail.purelymail.com ([34.202.193.197]:36546)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <spwhitton@HIDDEN>)
 id 1vVDhD-0007sJ-Du
 for 80012 <at> debbugs.gnu.org; Mon, 15 Dec 2025 13:53:24 -0500
DKIM-Signature: a=rsa-sha256;
 b=gnT1sDssSFvGILhk3CoOTNBe3a5gl0NB/UiKf5w++LoRZcrg9ndEQgJk9V0uMBMpRAEo8ReSdl809hV7+UVhYo3W1nnIsl0d90zacoBtgm5bOMW+t9nhJmod8l+mET6EwaGBkF08N3UQclxuxXKfEhFqyU98e7JVMJQvSTVkSJ69JW11/UFxGOjENvqIjqi9El79+ZMPQiNnkQ4o0S/6e4I+x+xJbdx9ZsxNvX1TMSL70cPZjtohowX5k08VLwe/KRX8gw/yQXdPtRhXOYRZDMVDFlFocaCfObKaqZMMNcAs2E9y5EGUII6j2mNegOfFYnlRuH593fDIdSMCKXkm3Q==;
 s=purelymail1; d=spwhitton.name; v=1;
 bh=h8LQZ8OcfnfdZVTSS1WX6wsI1zTfeCSnLiMXFzNSks0=;
 h=Received:Received:From:To:Subject:Date; 
DKIM-Signature: a=rsa-sha256;
 b=l7L0vqx2acmd0HDkSzdDKA3JN/YVg7ygtctZF8s1iYT+MuqJLlYnTXQAkcUeeQFVlLlPBwWC2cBD7MEMoHflItSmzqcB6pZce/dSItg4Mt0FSv1oECSX8lwdxYGIzuctD44JlIDKccIxSoM/7vlwAU6p5RwdIM9knLkyVWJZmoWLbHKxMRP7dMdIoEnr+BAh7NihycoksmZf2O9x3nYxBilNrTaz2St+uPS1hYLrMEknpVOejeHKzXY354nST5rbA7dw4x2fJAO5o28ipsTmNibtOK98WUHe7wBgWOVcb9TwqGIZaQfDLGLehRLZITU0FrNZFemM6HShyJOWnVEF7Q==;
 s=purelymail1; d=purelymail.com; v=1;
 bh=h8LQZ8OcfnfdZVTSS1WX6wsI1zTfeCSnLiMXFzNSks0=;
 h=Feedback-ID:Received:Received:From:To:Subject:Date; 
Feedback-ID: 20115:3760:null:purelymail
X-Pm-Original-To: 80012 <at> debbugs.gnu.org
Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -940306555; 
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Mon, 15 Dec 2025 18:53:16 +0000 (UTC)
Received: by zephyr.silentflame.com (Postfix, from userid 1000)
 id 23BDF941014; Mon, 15 Dec 2025 18:53:16 +0000 (GMT)
From: Sean Whitton <spwhitton@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#80012: 31.0.50; native-comp-async-on-battery-power
 recursive require problem
In-Reply-To: <86pl8f625j.fsf@HIDDEN>
References: <878qf3ohgk.fsf@HIDDEN> <86v7i766u6.fsf@HIDDEN>
 <87jyynmx6f.fsf@HIDDEN> <86pl8f625j.fsf@HIDDEN>
Date: Mon, 15 Dec 2025 18:53:16 +0000
Message-ID: <878qf3mvab.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 80012
Cc: Andrea Corallo <acorallo@HIDDEN>,
 Stefan Monnier <monnier@HIDDEN>, 80012 <at> debbugs.gnu.org
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: -1.0 (-)

Hello,

On Mon 15 Dec 2025 at 08:16pm +02, Eli Zaretskii wrote:

>> So either:
>>
>> --8<---------------cut here---------------start------------->8---
>> diff --git a/lisp/emacs-lisp/comp-run.el b/lisp/emacs-lisp/comp-run.el
>> index 5e33b1bc318..6cfb2135676 100644
>> --- a/lisp/emacs-lisp/comp-run.el
>> +++ b/lisp/emacs-lisp/comp-run.el
>> @@ -189,6 +189,8 @@ native--compile-skip-on-battery-p
>>    ;; that this is the first time we've wanted to use the information
>>    ;; other than just for generating messages.
>>    (and-let* (((not native-comp-async-on-battery-power))
>> +             ((not (and load-in-progress
>> +                        (equal load-file-name (locate-library "battery")))))
>>               ((require 'battery))
>>               battery-status-function
>>               (res (funcall battery-status-function))
>> --8<---------------cut here---------------end--------------->8---
>>
>> or
>>
>> --8<---------------cut here---------------start------------->8---
>> diff --git a/lisp/emacs-lisp/comp-run.el b/lisp/emacs-lisp/comp-run.el
>> index 5e33b1bc318..4fce8f55510 100644
>> --- a/lisp/emacs-lisp/comp-run.el
>> +++ b/lisp/emacs-lisp/comp-run.el
>> @@ -189,7 +189,11 @@ native--compile-skip-on-battery-p
>>    ;; that this is the first time we've wanted to use the information
>>    ;; other than just for generating messages.
>>    (and-let* (((not native-comp-async-on-battery-power))
>> -             ((require 'battery))
>> +             ;; If we are already loading battery.el or dbus.el, just
>> +             ;; skip JIT compilation, for now (bug#80012).
>> +             ((condition-case e
>> +                  (require 'battery)
>> +                (recursive-require nil)))
>>               battery-status-function
>>               (res (funcall battery-status-function))
>>               ((or (member (cdr (assq ?L res)) '("off-line" "BAT" "Battery"))
>> --8<---------------cut here---------------end--------------->8---
>>
>> after defining recursive-require as a new error type.
>>
>> I prefer the latter.  WDYT?
>
> Not sure.  Why do you prefer the latter?

We're redundantly calling locate-library because require will do the
same filesystem search right afterwards.

> And let's hear from Stefan and Andrea.

Yes.

-- 
Sean Whitton




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

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


Received: (at 80012) by debbugs.gnu.org; 15 Dec 2025 18:17:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 15 13:17:16 2025
Received: from localhost ([127.0.0.1]:42808 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vVD8F-0005he-OI
	for submit <at> debbugs.gnu.org; Mon, 15 Dec 2025 13:17:16 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:54316)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1vVD8C-0005hK-Q5
 for 80012 <at> debbugs.gnu.org; Mon, 15 Dec 2025 13:17:14 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1vVD80-0005lu-It; Mon, 15 Dec 2025 13:17:03 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=UAXeI1CSmw70ELNxkNu18wEbxCZ+D2YnmEEfhwB/EjM=; b=WHslWjaGSdXmr1dUozvW
 kmRtNsw9WC0fOKfXUrekBX6MpwmUsJZ5wdXisNBEanJG9JOZvJaqDKtTdTcUCcq/e71XisD354xmN
 wR0e80Bbx5L4j0V36h4w3Q2Itx5IV9qQHYGtcDlmNl3l/AdQ/ul2Jcg0UyTGZXyvakt/B1NJJ6ewD
 iP+ntrgIPClh0KGZll1K2SZN0EHJ4k8FhLbToC3RMfG4/IO/5SN2ZD+awVzy+CkqQInFupxDiBdwW
 qBWjme9XdyPhwEtCRebfjX5dx0MX1wsrBkE8xesfBxFP3POYoR8cliuHavaz8lL8tPkNoQ2QLSVAZ
 PTkF2E855J9kgw==;
Date: Mon, 15 Dec 2025 20:16:56 +0200
Message-Id: <86pl8f625j.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Sean Whitton <spwhitton@HIDDEN>, Andrea Corallo <acorallo@HIDDEN>,
 Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <87jyynmx6f.fsf@HIDDEN> (message from Sean
 Whitton on Mon, 15 Dec 2025 18:12:24 +0000)
Subject: Re: bug#80012: 31.0.50; native-comp-async-on-battery-power
 recursive require problem
References: <878qf3ohgk.fsf@HIDDEN> <86v7i766u6.fsf@HIDDEN>
 <87jyynmx6f.fsf@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 80012
Cc: 80012 <at> debbugs.gnu.org
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 (---)

> From: Sean Whitton <spwhitton@HIDDEN>
> Date: Mon, 15 Dec 2025 18:12:24 +0000
> 
> Hello,
> 
> On Mon 15 Dec 2025 at 06:35pm +02, Eli Zaretskii wrote:
> 
> > Does the excerpt below from the doc string of 'load' help?
> >
> >   While the file is in the process of being loaded, the variable
> >   ‘load-in-progress’ is non-nil and the variable ‘load-file-name’
> >   is bound to the file’s name.
> 
> Thanks.  I used this suggestion to add some debug printing and the
> errors look like this
> 
> --8<---------------cut here---------------start------------->8---
> LIP t, LFN /home/swhitton/src/emacs/primary/lisp/net/dbus.elc
> Error muted by safe_call: (apply native--compile-async
> ("/home/swhitton/src/emacs/primary/lisp/comint.el" nil late)) signaled
> (error "Recursive ‘require’ for feature ‘dbus’")
> [...]
> LIP t, LFN /home/swhitton/src/emacs/primary/lisp/battery.elc
> Error muted by safe_call: (apply native--compile-async
> ("/home/swhitton/src/emacs/primary/lisp/gnus/gnus-dbus.el" nil late))
> signaled (error "Recursive ‘require’ for feature ‘battery’")
> --8<---------------cut here---------------end--------------->8---
> 
> i.e. the recursive requires happen because we are already trying to load
> either dbus or battery when native--compile-skip-on-battery-p tries to
> load battery.
> 
> I think we have to avoid loading battery.el if we are in this situation.
> There doesn't seem to be any alternative.  The question is, do we skip
> JIT compilation in that case?  I think it would be right to skip it.
> 
> So either:
> 
> --8<---------------cut here---------------start------------->8---
> diff --git a/lisp/emacs-lisp/comp-run.el b/lisp/emacs-lisp/comp-run.el
> index 5e33b1bc318..6cfb2135676 100644
> --- a/lisp/emacs-lisp/comp-run.el
> +++ b/lisp/emacs-lisp/comp-run.el
> @@ -189,6 +189,8 @@ native--compile-skip-on-battery-p
>    ;; that this is the first time we've wanted to use the information
>    ;; other than just for generating messages.
>    (and-let* (((not native-comp-async-on-battery-power))
> +             ((not (and load-in-progress
> +                        (equal load-file-name (locate-library "battery")))))
>               ((require 'battery))
>               battery-status-function
>               (res (funcall battery-status-function))
> --8<---------------cut here---------------end--------------->8---
> 
> or
> 
> --8<---------------cut here---------------start------------->8---
> diff --git a/lisp/emacs-lisp/comp-run.el b/lisp/emacs-lisp/comp-run.el
> index 5e33b1bc318..4fce8f55510 100644
> --- a/lisp/emacs-lisp/comp-run.el
> +++ b/lisp/emacs-lisp/comp-run.el
> @@ -189,7 +189,11 @@ native--compile-skip-on-battery-p
>    ;; that this is the first time we've wanted to use the information
>    ;; other than just for generating messages.
>    (and-let* (((not native-comp-async-on-battery-power))
> -             ((require 'battery))
> +             ;; If we are already loading battery.el or dbus.el, just
> +             ;; skip JIT compilation, for now (bug#80012).
> +             ((condition-case e
> +                  (require 'battery)
> +                (recursive-require nil)))
>               battery-status-function
>               (res (funcall battery-status-function))
>               ((or (member (cdr (assq ?L res)) '("off-line" "BAT" "Battery"))
> --8<---------------cut here---------------end--------------->8---
> 
> after defining recursive-require as a new error type.
> 
> I prefer the latter.  WDYT?

Not sure.  Why do you prefer the latter?

And let's hear from Stefan and Andrea.




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

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


Received: (at 80012) by debbugs.gnu.org; 15 Dec 2025 18:12:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 15 13:12:39 2025
Received: from localhost ([127.0.0.1]:42742 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vVD3m-0005Jn-FO
	for submit <at> debbugs.gnu.org; Mon, 15 Dec 2025 13:12:38 -0500
Received: from sendmail.purelymail.com ([34.202.193.197]:49172)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <spwhitton@HIDDEN>)
 id 1vVD3j-0005JW-0e
 for 80012 <at> debbugs.gnu.org; Mon, 15 Dec 2025 13:12:36 -0500
DKIM-Signature: a=rsa-sha256;
 b=WDRRLuKn/zhZZHouI5PBSM/9t5YLAX+E3Hr4xIk12gbUuNxNBmUfNUqb4Q2Q2qXMXYSeAfBCNsOSIZQ8Rfg2YxdojPuMMiso1BswsWiGJlX6rqd5FXGZIothftxsIAhlrWrvxd+G108v+tBn18ox75tls3zdmCWK94qs0i0hlQCcs8DdaqqTw/KVdo5YE54GyDanSaPhH7Yql1cFHMC6eNZcQM2Bx/Oz0LwAWdIBLUpXgnhBiEHTj+jKn5BRg3irgK+fELgawxiR3Uyjilw5B+sRzlj5ruVecweko0uapG2ql5dKi7YvhVgjoAI/Y8pC168HnQtYUQsW2qVtx2Cm3A==;
 s=purelymail1; d=spwhitton.name; v=1;
 bh=sv6XtogsfQEhw361sIzD5TNn007tx2YteQYXil896+Q=;
 h=Received:Received:From:To:Subject:Date; 
DKIM-Signature: a=rsa-sha256;
 b=k15LbMO1BWwmS/GEEcgFx0uAbBgzDoDRwX3ZZ2Dqij05OeKvjyTmMFhczvsqVco9k05h22a3cJI3+psHPDXxmUuBR4TZZAdvhksivJ8A4NFfB3PjFo9Yb6WtDRKLWmMq0yajxf+fG8VWkrUjcpetn1o60pc9Zrj8PtEPX2HJH59/IYPcsnEIUCQB1JhidfuFmtGnlsjQ2Fa7eW/cU+gjVsLfx19Q+9xfUco19kMG70KXiIxvWO7lT2Jl5HN0+7UlqYvyHKTNrI6R20KyCoDKysu373TcItSVMD8cu1FgwAUELdZSiTtSx7H7ZXVc0dm7vTFybYbYBeAroUOd4zQwbA==;
 s=purelymail1; d=purelymail.com; v=1;
 bh=sv6XtogsfQEhw361sIzD5TNn007tx2YteQYXil896+Q=;
 h=Feedback-ID:Received:Received:From:To:Subject:Date; 
Feedback-ID: 20115:3760:null:purelymail
X-Pm-Original-To: 80012 <at> debbugs.gnu.org
Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -767947080; 
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Mon, 15 Dec 2025 18:12:24 +0000 (UTC)
Received: by zephyr.silentflame.com (Postfix, from userid 1000)
 id 412E8941014; Mon, 15 Dec 2025 18:12:24 +0000 (GMT)
From: Sean Whitton <spwhitton@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>, 80012 <at> debbugs.gnu.org
Subject: Re: bug#80012: 31.0.50; native-comp-async-on-battery-power
 recursive require problem
In-Reply-To: <86v7i766u6.fsf@HIDDEN>
References: <878qf3ohgk.fsf@HIDDEN> <86v7i766u6.fsf@HIDDEN>
Date: Mon, 15 Dec 2025 18:12:24 +0000
Message-ID: <87jyynmx6f.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 80012
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: -1.0 (-)

Hello,

On Mon 15 Dec 2025 at 06:35pm +02, Eli Zaretskii wrote:

> Does the excerpt below from the doc string of 'load' help?
>
>   While the file is in the process of being loaded, the variable
>   =E2=80=98load-in-progress=E2=80=99 is non-nil and the variable =E2=80=
=98load-file-name=E2=80=99
>   is bound to the file=E2=80=99s name.

Thanks.  I used this suggestion to add some debug printing and the
errors look like this

--8<---------------cut here---------------start------------->8---
LIP t, LFN /home/swhitton/src/emacs/primary/lisp/net/dbus.elc
Error muted by safe_call: (apply native--compile-async
("/home/swhitton/src/emacs/primary/lisp/comint.el" nil late)) signaled
(error "Recursive =E2=80=98require=E2=80=99 for feature =E2=80=98dbus=E2=80=
=99")
[...]
LIP t, LFN /home/swhitton/src/emacs/primary/lisp/battery.elc
Error muted by safe_call: (apply native--compile-async
("/home/swhitton/src/emacs/primary/lisp/gnus/gnus-dbus.el" nil late))
signaled (error "Recursive =E2=80=98require=E2=80=99 for feature =E2=80=98b=
attery=E2=80=99")
--8<---------------cut here---------------end--------------->8---

i.e. the recursive requires happen because we are already trying to load
either dbus or battery when native--compile-skip-on-battery-p tries to
load battery.

I think we have to avoid loading battery.el if we are in this situation.
There doesn't seem to be any alternative.  The question is, do we skip
JIT compilation in that case?  I think it would be right to skip it.

So either:

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/emacs-lisp/comp-run.el b/lisp/emacs-lisp/comp-run.el
index 5e33b1bc318..6cfb2135676 100644
--- a/lisp/emacs-lisp/comp-run.el
+++ b/lisp/emacs-lisp/comp-run.el
@@ -189,6 +189,8 @@ native--compile-skip-on-battery-p
   ;; that this is the first time we've wanted to use the information
   ;; other than just for generating messages.
   (and-let* (((not native-comp-async-on-battery-power))
+             ((not (and load-in-progress
+                        (equal load-file-name (locate-library "battery")))=
))
              ((require 'battery))
              battery-status-function
              (res (funcall battery-status-function))
--8<---------------cut here---------------end--------------->8---

or

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/emacs-lisp/comp-run.el b/lisp/emacs-lisp/comp-run.el
index 5e33b1bc318..4fce8f55510 100644
--- a/lisp/emacs-lisp/comp-run.el
+++ b/lisp/emacs-lisp/comp-run.el
@@ -189,7 +189,11 @@ native--compile-skip-on-battery-p
   ;; that this is the first time we've wanted to use the information
   ;; other than just for generating messages.
   (and-let* (((not native-comp-async-on-battery-power))
-             ((require 'battery))
+             ;; If we are already loading battery.el or dbus.el, just
+             ;; skip JIT compilation, for now (bug#80012).
+             ((condition-case e
+                  (require 'battery)
+                (recursive-require nil)))
              battery-status-function
              (res (funcall battery-status-function))
              ((or (member (cdr (assq ?L res)) '("off-line" "BAT" "Battery"=
))
--8<---------------cut here---------------end--------------->8---

after defining recursive-require as a new error type.

I prefer the latter.  WDYT?

--=20
Sean Whitton




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

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


Received: (at 80012) by debbugs.gnu.org; 15 Dec 2025 16:36:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 15 11:36:10 2025
Received: from localhost ([127.0.0.1]:41832 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vVBYO-00080m-3Y
	for submit <at> debbugs.gnu.org; Mon, 15 Dec 2025 11:36:10 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:57780)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1vVBYI-0007zZ-1w
 for 80012 <at> debbugs.gnu.org; Mon, 15 Dec 2025 11:36:05 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1vVBYC-0004g7-A4; Mon, 15 Dec 2025 11:35:56 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=0bmrdeikELq0HgzdAe+ArdFeofs4MFHP4uMUvaUdxqQ=; b=gvMUwwLX+H9v7KxNYSHo
 AzPNbYY8pNpd964LRX3L3Cx+jxwK+P3gsu8FyesVxkBJmgN24K71DRv4if6U2pRkVhSbh1saP4NY9
 ZVlnGmWt+IDJKdvS0cuEP7aCXLVLnTVXt8mLGaqP10O1aFsFMDaV6YBRNUqUoxYEnFOIWT8I1f1y9
 1+65tJHb/XVF6/NEyLPsENwtL3PNM680bbLC/HFPZoy3uCEhANUBlYkn7x/PkAZ8w40AAt06HYRau
 FzK50MjoXBTyfyz5aUQcTuTDjq9rxW3M3hKyoFQjdVkkkK+xde9pTaT2MWabCTN8bJXATI9w2iGiu
 mPkdN+1irXcqVQ==;
Date: Mon, 15 Dec 2025 18:35:45 +0200
Message-Id: <86v7i766u6.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Sean Whitton <spwhitton@HIDDEN>
In-Reply-To: <878qf3ohgk.fsf@HIDDEN> (message from Sean
 Whitton on Mon, 15 Dec 2025 16:08:59 +0000)
Subject: Re: bug#80012: 31.0.50;
 native-comp-async-on-battery-power recursive require problem
References: <878qf3ohgk.fsf@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 80012
Cc: 80012 <at> debbugs.gnu.org
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 (---)

> From: Sean Whitton <spwhitton@HIDDEN>
> Date: Mon, 15 Dec 2025 16:08:59 +0000
> 
> Hello,
> 
> X-debbugs-cc: acorallo@HIDDEN
> 
> With native-comp-async-on-battery-power nil, I get lots of messages like
> these:
> 
> --8<---------------cut here---------------start------------->8---
> Error muted by safe_call: (apply native--compile-async
> ("/home/swhitton/src/emacs/primary/lisp/emacs-lisp/cl-macs.el" nil
> late)) signaled (error "Recursive ‘require’ for feature ‘dbus’")
> [...]
> Error muted by safe_call: (apply native--compile-async
> ("/home/swhitton/src/emacs/primary/lisp/wid-edit.el" nil late)) signaled
> (error "Recursive ‘require’ for feature ‘battery’")
> error in process sentinel: comp--run-async-workers: Recursive ‘require’
> for feature ‘battery’
> error in process sentinel: Recursive ‘require’ for feature ‘battery’
> --8<---------------cut here---------------end--------------->8---
> 
> I also see some about a recursive reuqire of the 'battery' feature in
> some cases that I haven't pinned down.
> 
> Since starting to use the User Lisp directory, Emacs hangs at startup:
> 
> --8<---------------cut here---------------start------------->8---
> Debugger entered--Lisp error: (quit)
>   dbus-call-method(:system "org.freedesktop.DBus" "/org/freedesktop/DBus" "org.freedesktop.DBus" "AddMatch" "type='signal',interface='org.freedesktop.DBus.Local',member='Disconnected',path='/org/freedesktop/DBus/Local'")
>   dbus-register-signal(:system nil "/org/freedesktop/DBus/Local" "org.freedesktop.DBus.Local" "Disconnected" dbus-handle-bus-disconnect)
>   dbus-init-bus(:system)
>   dbus--init()
>   byte-code(...)
>   require(dbus)
>   byte-code(...)
>   require(gnus-dbus)
>   byte-code(...)
>   require(gnus-start)
>   byte-code(...)
>   require(gnus-group)
>   byte-code(...)
>   require(gnus-sum)
>   byte-code(...)
>   require(ol-gnus)
>   org-load-modules-maybe()
>   orgtbl-mode()
>   run-hooks(change-major-mode-after-body-hook prog-mode-hook lisp-data-mode-hook emacs-lisp-mode-hook lisp-interaction-mode-hook)
>   apply(run-hooks change-major-mode-after-body-hook (prog-mode-hook lisp-data-mode-hook emacs-lisp-mode-hook lisp-interaction-mode-hook))
>   run-mode-hooks(lisp-interaction-mode-hook)
>   lisp-interaction-mode()
>   command-line()
>   normal-top-level()
> --8<---------------cut here---------------end--------------->8---
> 
> The most minimal init.el that causes the hang that I have been able to
> come up with:
> 
> --8<---------------cut here---------------start------------->8---
> ;;; -*- lexical-binding:t; -*-
> 
> (setq native-comp-async-on-battery-power nil)
> (setq debug-on-quit t)
> (require 'org-table)
> (add-hook 'lisp-interaction-mode-hook #'orgtbl-mode)
> --8<---------------cut here---------------end--------------->8---
> 
> ... but it only works if I make some other idiosyncracies true
> (e.g. early-init.el exists as a symlink to a file with no content except
> enabling lexical binding).  In other words, it's some sort of async
> issue that is hard to reliably trigger.
> 
> With native-comp-async-on-battery-power set to nil I can't reproduce the
> hang, and there are no messages.
> 
> So I think the problem is probably the (require 'battery) in
> native--compile-skip-on-battery-p.  Presumably it gets executed while
> we're already trying to load battery.el?  Should it be guarded with some
> code looking at load-file-name?

Does the excerpt below from the doc string of 'load' help?

  While the file is in the process of being loaded, the variable
  ‘load-in-progress’ is non-nil and the variable ‘load-file-name’
  is bound to the file’s name.




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

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


Received: (at submit) by debbugs.gnu.org; 15 Dec 2025 16:09:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 15 11:09:37 2025
Received: from localhost ([127.0.0.1]:41585 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vVB8i-0006AZ-Kj
	for submit <at> debbugs.gnu.org; Mon, 15 Dec 2025 11:09:37 -0500
Received: from lists.gnu.org ([2001:470:142::17]:55002)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <spwhitton@HIDDEN>)
 id 1vVB8f-0006AD-BZ
 for submit <at> debbugs.gnu.org; Mon, 15 Dec 2025 11:09:34 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <spwhitton@HIDDEN>)
 id 1vVB8I-0002oH-3o
 for bug-gnu-emacs@HIDDEN; Mon, 15 Dec 2025 11:09:13 -0500
Received: from sendmail.purelymail.com ([34.202.193.197])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <spwhitton@HIDDEN>)
 id 1vVB8D-0003Tw-AM
 for bug-gnu-emacs@HIDDEN; Mon, 15 Dec 2025 11:09:08 -0500
DKIM-Signature: a=rsa-sha256;
 b=aeW9AyDUtIRf5rv5qTuE6txIpvTpKo2o92e1WcJMA9diKWO/eJXQWw9tIS2azW9ONXcTMSCvyfXfpyZAEP2gHZkTMj3prGYVnG6cP9lpaPIQsuVV1W9owzXgOhnty3Bg9JT5rVmqOe5h07KStM4tQNnIq9ZQWG2x4l8UHT7x/Dh5noTD1UnEWN0uYgQDwVmvZzolPgEgMvevfMUojMHjPixgLwmdeswhfJJkAoGsS7j148Wf5fUkLGu/02JFTqCNp58B6GwSZgm78TqGxtFW+Jt6oAtHw/zHQ0XHHJPDjvkMyioEn23XI5czuZsahl+0sMoeW53c9ECx2p2eCceXRw==;
 s=purelymail1; d=spwhitton.name; v=1;
 bh=kJKUoTaEvQuZiX2kQpb7HD0kOVGdXtFQSYIpw8V14N4=;
 h=Received:Received:From:To:Subject:Date; 
DKIM-Signature: a=rsa-sha256;
 b=AdoXSQyT5sr1UQe3Dm5KorfpmTVBHrrqce0HWjLJCGU+jCFPI/cjBwsR2+Yi09IgdPs8/lmr8BVBZd+l9NWZinzmjdbbyxhA5+aI4H9hTu3JAM67aTpDzTmcvXMMVyw/ZMmZzadt/evQejzs2s4ykXhz2PTQeuVNfwooZg4S0wFdtU+HVyCcu2oaheDENoFd4L+UcpmAZ4oxL1gpF2lxWbxg4GBbMrBmS652W0/KqcGfyEDuCK10+k9/bS8NTn69w0R8mLHSy+Fct63veiM5CJv3/EOWx0tq7SvPIKLhW+PcfjH4XTEQRi6RDM+00qW4ZlL2mgL+CTFSat6bFFrm0g==;
 s=purelymail1; d=purelymail.com; v=1;
 bh=kJKUoTaEvQuZiX2kQpb7HD0kOVGdXtFQSYIpw8V14N4=;
 h=Feedback-ID:Received:Received:From:To:Subject:Date; 
Feedback-ID: 20115:3760:null:purelymail
X-Pm-Original-To: bug-gnu-emacs@HIDDEN
Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -399228351
 for <bug-gnu-emacs@HIDDEN>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Mon, 15 Dec 2025 16:09:00 +0000 (UTC)
Received: by zephyr.silentflame.com (Postfix, from userid 1000)
 id BC252941014; Mon, 15 Dec 2025 16:08:59 +0000 (GMT)
From: Sean Whitton <spwhitton@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 31.0.50; native-comp-async-on-battery-power recursive require problem
Date: Mon, 15 Dec 2025 16:08:59 +0000
Message-ID: <878qf3ohgk.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass client-ip=34.202.193.197;
 envelope-from=spwhitton@HIDDEN; helo=sendmail.purelymail.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,
 RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001,
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001,
 SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
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: -0.0 (/)

Hello,

X-debbugs-cc: acorallo@HIDDEN

With native-comp-async-on-battery-power nil, I get lots of messages like
these:

--8<---------------cut here---------------start------------->8---
Error muted by safe_call: (apply native--compile-async
("/home/swhitton/src/emacs/primary/lisp/emacs-lisp/cl-macs.el" nil
late)) signaled (error "Recursive =E2=80=98require=E2=80=99 for feature =E2=
=80=98dbus=E2=80=99")
[...]
Error muted by safe_call: (apply native--compile-async
("/home/swhitton/src/emacs/primary/lisp/wid-edit.el" nil late)) signaled
(error "Recursive =E2=80=98require=E2=80=99 for feature =E2=80=98battery=E2=
=80=99")
error in process sentinel: comp--run-async-workers: Recursive =E2=80=98requ=
ire=E2=80=99
for feature =E2=80=98battery=E2=80=99
error in process sentinel: Recursive =E2=80=98require=E2=80=99 for feature =
=E2=80=98battery=E2=80=99
--8<---------------cut here---------------end--------------->8---

I also see some about a recursive reuqire of the 'battery' feature in
some cases that I haven't pinned down.

Since starting to use the User Lisp directory, Emacs hangs at startup:

--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (quit)
  dbus-call-method(:system "org.freedesktop.DBus" "/org/freedesktop/DBus" "=
org.freedesktop.DBus" "AddMatch" "type=3D'signal',interface=3D'org.freedesk=
top.DBus.Local',member=3D'Disconnected',path=3D'/org/freedesktop/DBus/Local=
'")
  dbus-register-signal(:system nil "/org/freedesktop/DBus/Local" "org.freed=
esktop.DBus.Local" "Disconnected" dbus-handle-bus-disconnect)
  dbus-init-bus(:system)
  dbus--init()
  byte-code(...)
  require(dbus)
  byte-code(...)
  require(gnus-dbus)
  byte-code(...)
  require(gnus-start)
  byte-code(...)
  require(gnus-group)
  byte-code(...)
  require(gnus-sum)
  byte-code(...)
  require(ol-gnus)
  org-load-modules-maybe()
  orgtbl-mode()
  run-hooks(change-major-mode-after-body-hook prog-mode-hook lisp-data-mode=
-hook emacs-lisp-mode-hook lisp-interaction-mode-hook)
  apply(run-hooks change-major-mode-after-body-hook (prog-mode-hook lisp-da=
ta-mode-hook emacs-lisp-mode-hook lisp-interaction-mode-hook))
  run-mode-hooks(lisp-interaction-mode-hook)
  lisp-interaction-mode()
  command-line()
  normal-top-level()
--8<---------------cut here---------------end--------------->8---

The most minimal init.el that causes the hang that I have been able to
come up with:

--8<---------------cut here---------------start------------->8---
;;; -*- lexical-binding:t; -*-

(setq native-comp-async-on-battery-power nil)
(setq debug-on-quit t)
(require 'org-table)
(add-hook 'lisp-interaction-mode-hook #'orgtbl-mode)
--8<---------------cut here---------------end--------------->8---

... but it only works if I make some other idiosyncracies true
(e.g. early-init.el exists as a symlink to a file with no content except
enabling lexical binding).  In other words, it's some sort of async
issue that is hard to reliably trigger.

With native-comp-async-on-battery-power set to nil I can't reproduce the
hang, and there are no messages.

So I think the problem is probably the (require 'battery) in
native--compile-skip-on-battery-p.  Presumably it gets executed while
we're already trying to load battery.el?  Should it be guarded with some
code looking at load-file-name?

--=20
Sean Whitton




Acknowledgement sent to Sean Whitton <spwhitton@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#80012; 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: Tue, 16 Dec 2025 12:30:02 UTC

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