GNU logs - #66096, boring messages


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#66096: High CPU usage, basically runaway emacs with visit to bidi_cache_search on and off?
Resent-From: "ISHIKAWA,chiaki" <ishikawa@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 19 Sep 2023 04:13:01 +0000
Resent-Message-ID: <handler.66096.B.169509674229413 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 66096
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 66096 <at> debbugs.gnu.org
Cc: "ishikawa, chiaki" <ishikawa@HIDDEN>
X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.169509674229413
          (code B ref -1); Tue, 19 Sep 2023 04:13:01 +0000
Received: (at submit) by debbugs.gnu.org; 19 Sep 2023 04:12:22 +0000
Received: from localhost ([127.0.0.1]:55103 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qiS62-0007eL-78
	for submit <at> debbugs.gnu.org; Tue, 19 Sep 2023 00:12:22 -0400
Received: from lists.gnu.org ([2001:470:142::17]:33350)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ishikawa@HIDDEN>) id 1qiS5x-0007e3-7O
 for submit <at> debbugs.gnu.org; Tue, 19 Sep 2023 00:12:21 -0400
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 <ishikawa@HIDDEN>)
 id 1qiS5i-0007FJ-TV
 for bug-gnu-emacs@HIDDEN; Tue, 19 Sep 2023 00:12:02 -0400
Received: from mail101.siriuscloud.jp ([219.118.72.101]
 helo=mail01.SiriusCloud.jp) by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <ishikawa@HIDDEN>) id 1qiS5e-0006uN-Pk
 for bug-gnu-emacs@HIDDEN; Tue, 19 Sep 2023 00:12:01 -0400
Received: from [192.168.0.77] (M106073032161.v4.enabler.ne.jp [106.73.32.161])
 (Authenticated sender: ishikawa@HIDDEN)
 by access01.SiriusCloud.jp (Postfix) with ESMTPA id 4RqSsf6Pjlz35twCJ;
 Tue, 19 Sep 2023 13:11:50 +0900 (JST)
Authentication-Results: access01.SiriusCloud.jp; dkim=none; dkim-atps=neutral
Message-ID: <1808d5a1-3ee6-d675-3ad3-c6bcc2fe5e36@HIDDEN>
Date: Tue, 19 Sep 2023 13:12:33 +0900
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
 Thunderbird/102.15.1
Content-Language: en-US
From: "ISHIKAWA,chiaki" <ishikawa@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=219.118.72.101;
 envelope-from=ishikawa@HIDDEN; helo=mail01.SiriusCloud.jp
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
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 (/)

High CPU usage, basically runaway emacs with visit to bidi_cache_search 
on and off?

Hi,

Environment:
OS GNU/Debian Linux  X86_64
Emacs version
GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, 
cairo version 1.16.0) of 2023-08-01
I compiled emacs using gcc.

Has anyone seen emacs 29.1 spending CPU way too high, basically went
into an infinite loop of some sort, and could not be interrupted by
Control-G?  Basically it is in a runaway state.
I found that the stacktraces show that bidi_cache_search
and friends are visited now and then.  It is not the recursive blowup 
probably since the stack depth is quite limited during my observation.


I have experienced this issue this morning.  Observing the stack
backtrace by monitoring the runaway emacs using gdb, I was surprised
to see many appearances of bidi_cache_search that were observed from
time to time while I do control-C to stop emacs and monitor
stacktrace, and the continue for a few seconds, and interrupt it again
with control-C.  After letting emacs run in this manner for about 5
minutes, I had tp kill emacs.  I had to edit the file by a deadline and 
could not continue debugging. :-(

At the end is a single stacktrace with bidi_cache_search at the top.
I have seen this occurring multiple times. My hitting control-C to emacs 
to enter gdb interaction means that the chance of hitting a particular 
stacktrace pattern is small and seeing the same pattern multiple times 
means that that pattern happens quite often.

The file I was editing is a Japanese text file.  Sorry, it contains 
proprietary information and I can't share it immediately.  However, I
will be editing it again with emacs this afternoon and if the problem 
recurs, I will try to redact it as much as possible and see if the
runaway problem recurs then.

I have a dozen or so more different stacktraces during gdb monitoring.
If someone wants to see the log, I can post it.
What is the preferred URL where I can paste the whole gdb session?

TIA.

Regars,
Chiaki

One stacktrace with bidi_cache_searh at the top.
I notice that charpos 358 was near the end of the file (probably at the 
end?) when I had to kill the emacs..
Sorry I had to recover the edited file after killing emacs, and it may 
no longer contain the exact buffer data when the problem occurred.

thread 1 "emacs" received signal SIGINT, Interrupt.
0x0000556f1905af04 in bidi_cache_search (charpos=charpos@entry=358,
     dir=dir@entry=1, level=-1) at bidi.c:660
660          if (charpos < bidi_cache[bidi_cache_last_idx].charpos)
(gdb) where
#0  0x0000556f1905af04 in bidi_cache_search
     (charpos=charpos@entry=358, dir=dir@entry=1, level=-1) at bidi.c:660
#1  0x0000556f1905b8a9 in bidi_cache_find
     (charpos=358, resolved_only=resolved_only@entry=false, 
bidi_it=bidi_it@entry=0x7ffeb7caae48) at bidi.c:877
#2  0x0000556f1905db97 in bidi_resolve_brackets
     (bidi_it=bidi_it@entry=0x7ffeb7caae48) at bidi.c:2883
#3  0x0000556f1905df79 in bidi_resolve_neutral
     (bidi_it=bidi_it@entry=0x7ffeb7caae48) at bidi.c:3010
#4  0x0000556f1905e4a1 in bidi_type_of_next_char (bidi_it=0x7ffeb7caae48)
     at bidi.c:3215
#5  bidi_level_of_next_char (bidi_it=bidi_it@entry=0x7ffeb7caae48)
     at bidi.c:3282
#6  0x0000556f1905f60e in bidi_move_to_visually_next
     (bidi_it=bidi_it@entry=0x7ffeb7caae48) at bidi.c:3485
#7  0x0000556f18fe0d7a in set_iterator_to_next
     (it=0x7ffeb7caa410, reseat_p=<optimized out>) at xdisp.c:8588
#8  0x0000556f18fdcb8d in move_it_in_display_line_to
     (it=it@entry=0x7ffeb7caa410, to_charpos=to_charpos@entry=2078, 
to_x=to_x@entry=-1, op=op@entry=MOVE_TO_POS) at xdisp.c:10268
#9  0x0000556f18fe1b88 in move_it_to
     (it=it@entry=0x7ffeb7caa410, to_charpos=2078, to_x=to_x@entry=-1, 
to_y=to_y@entry=-1, to_vpos=to_vpos@entry=-1, op=op@entry=8) at 
xdisp.c:10623
#10 0x0000556f18fe358c in resize_mini_window (w=0x556f1a3b4240, 
exact_p=true)
     at xdisp.c:12778
#11 0x0000556f18fc973a in with_echo_area_buffer
     (w=0x556f1a3b4240, which=which@entry=0, fn=fn@entry=0x556f18fe4250 
<resize_mini_window_1>, a1=0x556f1a3b4240, a2=0x30) at xdisp.c:12422
#12 0x0000556f18ff5269 in resize_echo_area_exactly () at xdisp.c:12678
#13 0x0000556f190de46d in command_loop_1 () at keyboard.c:1528
#14 0x0000556f19156377 in internal_condition_case
     (bfun=bfun@entry=0x556f190ddcb0 <command_loop_1>, 
handlers=handlers@entry=0x90, hfun=hfun@entry=0x556f190d0f40 
<cmd_error>) at eval.c:1474
#15 0x0000556f190c9bf6 in command_loop_2 (handlers=handlers@entry=0x90)
     at keyboard.c:1133
#16 0x0000556f191562d1 in internal_catch
     (tag=tag@entry=0x10080, func=func@entry=0x556f190c9bd0 
<command_loop_2>, arg=arg@entry=0x90) at eval.c:1197
#17 0x0000556f190c9b91 in command_loop () at keyboard.c:1111
#18 0x0000556f190d0af1 in recursive_edit_1 () at keyboard.c:720
#19 0x0000556f190d0e70 in Frecursive_edit () at keyboard.c:803
#20 0x0000556f18fa3cf2 in main (argc=7, argv=0x7ffeb7cabd08) at emacs.c:2529
(gdb) c







Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: "ISHIKAWA,chiaki" <ishikawa@HIDDEN>
Subject: bug#66096: Acknowledgement (High CPU usage, basically runaway
 emacs with visit to bidi_cache_search on and off?)
Message-ID: <handler.66096.B.169509674229413.ack <at> debbugs.gnu.org>
References: <1808d5a1-3ee6-d675-3ad3-c6bcc2fe5e36@HIDDEN>
X-Gnu-PR-Message: ack 66096
X-Gnu-PR-Package: emacs
Reply-To: 66096 <at> debbugs.gnu.org
Date: Tue, 19 Sep 2023 04:13:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-gnu-emacs@HIDDEN

If you wish to submit further information on this problem, please
send it to 66096 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
66096: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D66096
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#66096: High CPU usage, basically runaway emacs with visit to bidi_cache_search on and off?
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 19 Sep 2023 11:05:01 +0000
Resent-Message-ID: <handler.66096.B66096.1695121469517 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66096
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: "ISHIKAWA,chiaki" <ishikawa@HIDDEN>
Cc: 66096 <at> debbugs.gnu.org, ishikawa@HIDDEN
Received: via spool by 66096-submit <at> debbugs.gnu.org id=B66096.1695121469517
          (code B ref 66096); Tue, 19 Sep 2023 11:05:01 +0000
Received: (at 66096) by debbugs.gnu.org; 19 Sep 2023 11:04:29 +0000
Received: from localhost ([127.0.0.1]:55478 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qiYWr-00008H-4h
	for submit <at> debbugs.gnu.org; Tue, 19 Sep 2023 07:04:29 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:50842)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1qiYWl-000081-Hs
 for 66096 <at> debbugs.gnu.org; Tue, 19 Sep 2023 07:04:27 -0400
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 1qiYWV-00022e-5b; Tue, 19 Sep 2023 07:04:07 -0400
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=7m+fKzMVdJljJ+Mf7ebAu3sLlrnyyJD/V1TK+HpHR9s=; b=bRJBFWGeCn5sKo0JaxJp
 XWrGgHdX2JQWlQ7Tz9LUkOVMAmMjJp7YKZDDQdcK8eldBqny95U+5zyknYPnIAgoGtHlLObYO+38N
 f38Jl9QT6sCx/FLq+KO5IrHqTFFsgrhBYWoodT18Zj2I0h+Nq7NbqAD6HXV0Vpul7NOkJ4aej3frU
 vd7u8gw/Y5+EoRi8VWxM2UAbbncyGr3OXe8wDXCAKuuqPnzVE8gJKljhIJ74mccJZZlfM6e+Y6Ezl
 qYJ2KY9lfToYOBiAC6HQwlytkDvPuyN3obVBa8m4dGArrg87oljYPZhJ5EbsJjNEHDHgtStXafVKa
 zy/bhr7bDaA5pg==;
Date: Tue, 19 Sep 2023 14:04:08 +0300
Message-Id: <834jjqe85z.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <1808d5a1-3ee6-d675-3ad3-c6bcc2fe5e36@HIDDEN>
 (ishikawa@HIDDEN)
References: <1808d5a1-3ee6-d675-3ad3-c6bcc2fe5e36@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
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 (---)

> Cc: "ishikawa, chiaki" <ishikawa@HIDDEN>
> Date: Tue, 19 Sep 2023 13:12:33 +0900
> From: "ISHIKAWA,chiaki" <ishikawa@HIDDEN>
> 
> High CPU usage, basically runaway emacs with visit to bidi_cache_search 
> on and off?
> 
> Hi,
> 
> Environment:
> OS GNU/Debian Linux  X86_64
> Emacs version
> GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, 
> cairo version 1.16.0) of 2023-08-01
> I compiled emacs using gcc.
> 
> Has anyone seen emacs 29.1 spending CPU way too high, basically went
> into an infinite loop of some sort, and could not be interrupted by
> Control-G?  Basically it is in a runaway state.
> I found that the stacktraces show that bidi_cache_search
> and friends are visited now and then.  It is not the recursive blowup 
> probably since the stack depth is quite limited during my observation.
> 
> 
> I have experienced this issue this morning.  Observing the stack
> backtrace by monitoring the runaway emacs using gdb, I was surprised
> to see many appearances of bidi_cache_search that were observed from
> time to time while I do control-C to stop emacs and monitor
> stacktrace, and the continue for a few seconds, and interrupt it again
> with control-C.  After letting emacs run in this manner for about 5
> minutes, I had tp kill emacs.  I had to edit the file by a deadline and 
> could not continue debugging. :-(
> 
> At the end is a single stacktrace with bidi_cache_search at the top.
> I have seen this occurring multiple times. My hitting control-C to emacs 
> to enter gdb interaction means that the chance of hitting a particular 
> stacktrace pattern is small and seeing the same pattern multiple times 
> means that that pattern happens quite often.

The backtrace shows we were resizing the mini-window, but it doesn't
tell where and why we were looping.

(The bidi_cache_search part is probably a red herring: that function
is indeed called very frequently when Emacs performs display and
layout calculations -- which is not surprising, since that's why the
bidi cache exists: to provide cache hits whenever possible.)

So it is important to have a file and the sequence of commands that
trigger this.  Please try to produce such a file and a recipe to
reproduce the problem.

Alternatively, you can use the technique described in etc/DEBUG for
finding where Emacs loops, see there under "If the symptom of the bug
is that Emacs fails to respond".  I think even if you do discover
where it loops, we'd need an example file to see why, though.

> I have a dozen or so more different stacktraces during gdb monitoring.
> If someone wants to see the log, I can post it.
> What is the preferred URL where I can paste the whole gdb session?

You can post them here, perhaps compressed.  However, if they are all
of the same kind, i.e. start with resize_echo_area_exactly, then I
don't think more backtraces alone will help.

Thanks.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#66096: High CPU usage, basically runaway emacs with visit to bidi_cache_search on and off?
Resent-From: "ISHIKAWA,chiaki" <ishikawa@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Wed, 20 Sep 2023 07:09:02 +0000
Resent-Message-ID: <handler.66096.B66096.16951937149454 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66096
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 66096 <at> debbugs.gnu.org, "ishikawa, chiaki" <ishikawa@HIDDEN>
Received: via spool by 66096-submit <at> debbugs.gnu.org id=B66096.16951937149454
          (code B ref 66096); Wed, 20 Sep 2023 07:09:02 +0000
Received: (at 66096) by debbugs.gnu.org; 20 Sep 2023 07:08:34 +0000
Received: from localhost ([127.0.0.1]:58175 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qirK5-0002SQ-MW
	for submit <at> debbugs.gnu.org; Wed, 20 Sep 2023 03:08:34 -0400
Received: from mail06.siriuscloud.jp ([219.118.72.6]:41118)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ishikawa@HIDDEN>) id 1qirK2-0002S5-5C
 for 66096 <at> debbugs.gnu.org; Wed, 20 Sep 2023 03:08:32 -0400
Received: from [192.168.0.77] (M106073032161.v4.enabler.ne.jp [106.73.32.161])
 (Authenticated sender: ishikawa@HIDDEN)
 by access06.SiriusCloud.jp (Postfix) with ESMTPA id 4Rr8kp22gVz60Nb;
 Wed, 20 Sep 2023 16:08:18 +0900 (JST)
Authentication-Results: access06.SiriusCloud.jp; dkim=none
 reason="no signature"; dkim-adsp=none (unprotected policy);
 dkim-atps=neutral
Content-Type: multipart/mixed; boundary="------------kcjWW2kzp4JrMOBLWEZZB3WC"
Message-ID: <80682fbe-b5ac-4605-b8e5-7baac2d71da5@HIDDEN>
Date: Wed, 20 Sep 2023 16:09:03 +0900
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
References: <1808d5a1-3ee6-d675-3ad3-c6bcc2fe5e36@HIDDEN>
 <834jjqe85z.fsf@HIDDEN>
Content-Language: en-US
From: "ISHIKAWA,chiaki" <ishikawa@HIDDEN>
In-Reply-To: <834jjqe85z.fsf@HIDDEN>
X-Spam-Score: 0.0 (/)
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 (-)

This is a multi-part message in MIME format.
--------------kcjWW2kzp4JrMOBLWEZZB3WC
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

On 2023/09/19 20:04, Eli Zaretskii wrote:
>> Cc: "ishikawa, chiaki" <ishikawa@HIDDEN>
>> Date: Tue, 19 Sep 2023 13:12:33 +0900
>> From: "ISHIKAWA,chiaki" <ishikawa@HIDDEN>
>>
>> High CPU usage, basically runaway emacs with visit to bidi_cache_search
>> on and off?
>>
>> Hi,
>>
>> Environment:
>> OS GNU/Debian Linux  X86_64
>> Emacs version
>> GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38,
>> cairo version 1.16.0) of 2023-08-01
>> I compiled emacs using gcc.
>>
>> Has anyone seen emacs 29.1 spending CPU way too high, basically went
>> into an infinite loop of some sort, and could not be interrupted by
>> Control-G?  Basically it is in a runaway state.
>> I found that the stacktraces show that bidi_cache_search
>> and friends are visited now and then.  It is not the recursive blowup
>> probably since the stack depth is quite limited during my observation.
>>
>>
>> I have experienced this issue this morning.  Observing the stack
>> backtrace by monitoring the runaway emacs using gdb, I was surprised
>> to see many appearances of bidi_cache_search that were observed from
>> time to time while I do control-C to stop emacs and monitor
>> stacktrace, and the continue for a few seconds, and interrupt it again
>> with control-C.  After letting emacs run in this manner for about 5
>> minutes, I had tp kill emacs.  I had to edit the file by a deadline and
>> could not continue debugging. :-(
>>
>> At the end is a single stacktrace with bidi_cache_search at the top.
>> I have seen this occurring multiple times. My hitting control-C to emacs
>> to enter gdb interaction means that the chance of hitting a particular
>> stacktrace pattern is small and seeing the same pattern multiple times
>> means that that pattern happens quite often.
> The backtrace shows we were resizing the mini-window, but it doesn't
> tell where and why we were looping.
>
> (The bidi_cache_search part is probably a red herring: that function
> is indeed called very frequently when Emacs performs display and
> layout calculations -- which is not surprising, since that's why the
> bidi cache exists: to provide cache hits whenever possible.)
>
> So it is important to have a file and the sequence of commands that
> trigger this.  Please try to produce such a file and a recipe to
> reproduce the problem.
>
> Alternatively, you can use the technique described in etc/DEBUG for
> finding where Emacs loops, see there under "If the symptom of the bug
> is that Emacs fails to respond".  I think even if you do discover
> where it loops, we'd need an example file to see why, though.
>
>> I have a dozen or so more different stacktraces during gdb monitoring.
>> If someone wants to see the log, I can post it.
>> What is the preferred URL where I can paste the whole gdb session?
> You can post them here, perhaps compressed.  However, if they are all
> of the same kind, i.e. start with resize_echo_area_exactly, then I
> don't think more backtraces alone will help.
>
> Thanks.
>
Thank you for your comment.

There seem to be enough variation of the stacktrace patterns.

I am attaching the gdb session file as zipped archive.
As you suggested, it seems Emacs is trying to resize echo area, and is 
looping somehow.
resize_echo_area_exactly () seems to be always there.
It could be that it was trying to dump the S-expression that encodes the 
latest GC information after each GC.

I have the following code snippet to monitor GC issues on my PC for 
quite sometime.
But I have not seen this particular problem before.
The long pause I have seen before was strictly in GC-related routines.

(setq my-gc-statistics (make-vector 30 nil))

;;; The element is
;;; (append (memory-use-counts) (list gc-elapsed gcs-done))
;;; Each time the following function is called, the
;;; elements in the array is shifted toward the end.
;;; Use (message "%S" my-gc-statistics) to force the
;;; recording of my-gc-statistics value in *Messages* buffer for later 
analysis.


(defun update-my-gc-statistics ()
   (let ((i 28))
     (progn
      ;;; very unlike Lisp
      (while (<= 0 i)
        (progn (aset my-gc-statistics (+ 1 i) (aref my-gc-statistics i))
              (setq i (- i 1) )))
      (aset my-gc-statistics 0
            (append (memory-use-counts) (list gc-elapsed gcs-done)))
      ;;; print the latest one last so that I can see the glimpse in the 
narrow
      ;;; output window.
      (message "%S\n%S" (current-time-string) (pp (reverse 
my-gc-statistics))))))

(setq post-gc-hook 'update-my-gc-statistics)

For example, in one place, I see
#0  0x0000556f1905be9e in string_char_and_length
     (length=<synthetic pointer>, p=0x556f20d8a3d8 " 70337 417360 
2.323839139 50)\n (99058573 3875 59193441 34949 11084445 70337 417401 
2.391973008 51)]\n\"") at 
/home/ishikawa/repos/emacs-29.1/src/character.h:375

And that string is probably   from (append (memory-use-counts) (list 
gc-elapsed gcs-done))

Also I see recursive_edit at the bottom of the stakctrace.
Not sure why. Maybe I was doing some error recovery of Japanese input?


In any case, Emacs should not enter a state that cannot be interrupted 
by CONTROL-G for a long time IMHO.
(Or was it that the processing of control-G somehow resulted in the 
effort to widen echo area and emacs failed?)

TIA


Chiaki

--------------kcjWW2kzp4JrMOBLWEZZB3WC
Content-Type: application/x-zip-compressed;
 name="emacs-cant-be-interrupted-with-control-g.zip"
Content-Disposition: attachment;
 filename="emacs-cant-be-interrupted-with-control-g.zip"
Content-Transfer-Encoding: base64

UEsDBBQAAAAIAM19NFddK2Pzyh0AANz7AAAsAAAAZW1hY3MtY2FudC1iZS1pbnRlcnJ1cHRl
ZC13aXRoLWNvbnRyb2wtZy50eHTsXXt327aS/zv6FDjOnh67tWW+H75hetPESX1O6mQdp3fv
tl0ePiCJNzTJklRs73b3s+8MSD0IyLYoUYnVKq0piSSAmcFjfhgMBlExij55197fo0xSpZP/
+zeSFcS7GZI/yDCnGaFXXlD0CCG6ZFgkK4tjCX6QixivinWiWOR4lF7R46jO6BhSpcUxS3ek
2H35uMiD6ic5OrrJrxz2vX9Fk7Hv5d8O0qQ8wUtByyPNqt85Ze9kXkInL/azNBtn7rd9/K91
olliMSn+INM7EtwZUuCozG8dS79RFeBeV23dnHH/4Tu8EulEkualFAmyHIY+Ocoq2S0tpt6b
848s5f4r6kdeQmS1rxzJB+yz9zLNbvNoOCrJ/ssDokiKSl7nlJIP6aC89nJKXqfjJPTKKE0O
yVkS9Htvo4AmBSVv3r/9rH53QjB7+E4+07yAt4hK0pzEXklz8mxUltnJ8fEwGffTfHgcV0mL
42EW90flVfy8dzmKC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MXyiVolCvLTijzkVDdj0qwpnKuWjk3YqGcGbbe0MJnCFZ16vBmffbHCJwdfXm
0CrTXgARRetp052R/QIQJGKmHoAgNXGrAYiuJm6J+e8q2qrM/65VtEWs+CY8/NeDE/4nKIOH
ZUI7P579x88bsZH5r7yOdyb74I+cVof5K0eZNn8e/AtQSwECFAAUAAAACADNfTRXXStj88od
AADc+wAALAAAAAAAAAABACAAAAAAAAAAZW1hY3MtY2FudC1iZS1pbnRlcnJ1cHRlZC13aXRo
LWNvbnRyb2wtZy50eHRQSwUGAAAAAAEAAQBaAAAAFB4AAAAA

--------------kcjWW2kzp4JrMOBLWEZZB3WC--




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#66096: High CPU usage, basically runaway emacs with visit to bidi_cache_search on and off?
Resent-From: "ISHIKAWA,chiaki" <ishikawa@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Wed, 20 Sep 2023 07:17:02 +0000
Resent-Message-ID: <handler.66096.B66096.169519418410261 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66096
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 66096 <at> debbugs.gnu.org, "ishikawa, chiaki" <ishikawa@HIDDEN>
Received: via spool by 66096-submit <at> debbugs.gnu.org id=B66096.169519418410261
          (code B ref 66096); Wed, 20 Sep 2023 07:17:02 +0000
Received: (at 66096) by debbugs.gnu.org; 20 Sep 2023 07:16:24 +0000
Received: from localhost ([127.0.0.1]:58187 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qirRf-0002fQ-PY
	for submit <at> debbugs.gnu.org; Wed, 20 Sep 2023 03:16:24 -0400
Received: from mail06.siriuscloud.jp ([219.118.72.6]:37309)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ishikawa@HIDDEN>) id 1qirRc-0002f5-QF
 for 66096 <at> debbugs.gnu.org; Wed, 20 Sep 2023 03:16:22 -0400
Received: from [192.168.0.77] (M106073032161.v4.enabler.ne.jp [106.73.32.161])
 (Authenticated sender: ishikawa@HIDDEN)
 by access06.SiriusCloud.jp (Postfix) with ESMTPA id 4Rr8vr3hppz5gSZ;
 Wed, 20 Sep 2023 16:16:08 +0900 (JST)
Authentication-Results: access06.SiriusCloud.jp; dkim=none
 reason="no signature"; dkim-adsp=none (unprotected policy);
 dkim-atps=neutral
Message-ID: <4cdbc18c-9e36-4319-921d-fd99302ac957@HIDDEN>
Date: Wed, 20 Sep 2023 16:16:54 +0900
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Content-Language: en-US
References: <1808d5a1-3ee6-d675-3ad3-c6bcc2fe5e36@HIDDEN>
 <834jjqe85z.fsf@HIDDEN> <80682fbe-b5ac-4605-b8e5-7baac2d71da5@HIDDEN>
From: "ISHIKAWA,chiaki" <ishikawa@HIDDEN>
In-Reply-To: <80682fbe-b5ac-4605-b8e5-7baac2d71da5@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
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 (-)

Oh, I now notice that you are saying if resize_echo_area_exactly is 
always there, the backtraces won't help much.
Tough.
I think the routines called by resize_echo_area_exactly do not change 
the environeent to satisfy what resize_echo_area_exactly wamts, but
I think that will need detailed debugging.

Unfortunately, the problem did not recur yesterday afternoon and I could 
edit the file after "recover-file".

I will try to create more meaningful debug information when something 
similar happens.
It was really the first time in a few years when emacs could not be 
interrupted by control-G.
So, I am not sure if I hit the right condition easily.

TIA

Chiaki

On 2023/09/20 16:09, ISHIKAWA,chiaki wrote:
> On 2023/09/19 20:04, Eli Zaretskii wrote:
>>> Cc: "ishikawa, chiaki" <ishikawa@HIDDEN>
>>> Date: Tue, 19 Sep 2023 13:12:33 +0900
>>> From: "ISHIKAWA,chiaki" <ishikawa@HIDDEN>
>>>
>>> High CPU usage, basically runaway emacs with visit to bidi_cache_search
>>> on and off?
>>>
>>> Hi,
>>>
>>> Environment:
>>> OS GNU/Debian Linux  X86_64
>>> Emacs version
>>> GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38,
>>> cairo version 1.16.0) of 2023-08-01
>>> I compiled emacs using gcc.
>>>
>>> Has anyone seen emacs 29.1 spending CPU way too high, basically went
>>> into an infinite loop of some sort, and could not be interrupted by
>>> Control-G?  Basically it is in a runaway state.
>>> I found that the stacktraces show that bidi_cache_search
>>> and friends are visited now and then.  It is not the recursive blowup
>>> probably since the stack depth is quite limited during my observation.
>>>
>>>
>>> I have experienced this issue this morning.  Observing the stack
>>> backtrace by monitoring the runaway emacs using gdb, I was surprised
>>> to see many appearances of bidi_cache_search that were observed from
>>> time to time while I do control-C to stop emacs and monitor
>>> stacktrace, and the continue for a few seconds, and interrupt it again
>>> with control-C.  After letting emacs run in this manner for about 5
>>> minutes, I had tp kill emacs.  I had to edit the file by a deadline and
>>> could not continue debugging. :-(
>>>
>>> At the end is a single stacktrace with bidi_cache_search at the top.
>>> I have seen this occurring multiple times. My hitting control-C to 
>>> emacs
>>> to enter gdb interaction means that the chance of hitting a particular
>>> stacktrace pattern is small and seeing the same pattern multiple times
>>> means that that pattern happens quite often.
>> The backtrace shows we were resizing the mini-window, but it doesn't
>> tell where and why we were looping.
>>
>> (The bidi_cache_search part is probably a red herring: that function
>> is indeed called very frequently when Emacs performs display and
>> layout calculations -- which is not surprising, since that's why the
>> bidi cache exists: to provide cache hits whenever possible.)
>>
>> So it is important to have a file and the sequence of commands that
>> trigger this.  Please try to produce such a file and a recipe to
>> reproduce the problem.
>>
>> Alternatively, you can use the technique described in etc/DEBUG for
>> finding where Emacs loops, see there under "If the symptom of the bug
>> is that Emacs fails to respond".  I think even if you do discover
>> where it loops, we'd need an example file to see why, though.
>>
>>> I have a dozen or so more different stacktraces during gdb monitoring.
>>> If someone wants to see the log, I can post it.
>>> What is the preferred URL where I can paste the whole gdb session?
>> You can post them here, perhaps compressed.  However, if they are all
>> of the same kind, i.e. start with resize_echo_area_exactly, then I
>> don't think more backtraces alone will help.
>>
>> Thanks.
>>
> Thank you for your comment.
>
> There seem to be enough variation of the stacktrace patterns.
>
> I am attaching the gdb session file as zipped archive.
> As you suggested, it seems Emacs is trying to resize echo area, and is 
> looping somehow.
> resize_echo_area_exactly () seems to be always there.
> It could be that it was trying to dump the S-expression that encodes 
> the latest GC information after each GC.
>
> I have the following code snippet to monitor GC issues on my PC for 
> quite sometime.
> But I have not seen this particular problem before.
> The long pause I have seen before was strictly in GC-related routines.
>
> (setq my-gc-statistics (make-vector 30 nil))
>
> ;;; The element is
> ;;; (append (memory-use-counts) (list gc-elapsed gcs-done))
> ;;; Each time the following function is called, the
> ;;; elements in the array is shifted toward the end.
> ;;; Use (message "%S" my-gc-statistics) to force the
> ;;; recording of my-gc-statistics value in *Messages* buffer for later 
> analysis.
>
>
> (defun update-my-gc-statistics ()
>   (let ((i 28))
>     (progn
>      ;;; very unlike Lisp
>      (while (<= 0 i)
>        (progn (aset my-gc-statistics (+ 1 i) (aref my-gc-statistics i))
>              (setq i (- i 1) )))
>      (aset my-gc-statistics 0
>            (append (memory-use-counts) (list gc-elapsed gcs-done)))
>      ;;; print the latest one last so that I can see the glimpse in 
> the narrow
>      ;;; output window.
>      (message "%S\n%S" (current-time-string) (pp (reverse 
> my-gc-statistics))))))
>
> (setq post-gc-hook 'update-my-gc-statistics)
>
> For example, in one place, I see
> #0  0x0000556f1905be9e in string_char_and_length
>     (length=<synthetic pointer>, p=0x556f20d8a3d8 " 70337 417360 
> 2.323839139 50)\n (99058573 3875 59193441 34949 11084445 70337 417401 
> 2.391973008 51)]\n\"") at 
> /home/ishikawa/repos/emacs-29.1/src/character.h:375
>
> And that string is probably   from (append (memory-use-counts) (list 
> gc-elapsed gcs-done))
>
> Also I see recursive_edit at the bottom of the stakctrace.
> Not sure why. Maybe I was doing some error recovery of Japanese input?
>
>
> In any case, Emacs should not enter a state that cannot be interrupted 
> by CONTROL-G for a long time IMHO.
> (Or was it that the processing of control-G somehow resulted in the 
> effort to widen echo area and emacs failed?)
>
> TIA
>
>
> Chiaki







Last modified: Wed, 20 Sep 2023 07:30:02 UTC

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