Subject: Re: bug#61436: Emacs Freezing With Java Files

From: Jens Schmidt <[email-masked]>
Date: Mon, 09 Oct 2023 22:26:31 +0200

found 61436 29.1.50
found 61436 30.0.50
thanks

Hank Greenburg <[email-masked]> writes:
> This works just fine until which-function-mode is
> activated. After that is activated I can scroll through maybe
> twice before it freezes.

I can confirm both on emacs-29 and on master.  (Actually, I was hoping
for another case of my bug#60768 wracking havoc, but this issue is
actually something different.  Even though `beginning-of-defun' is also
involved here through `which-function' calls ...)

A slightly easier to follow reproducer:

- Ensure package "hyperbole" is installed.  (Its only role in this issue
  seems to be a "background load generator", but I'm not 100% sure
  here.)

- Save Hank's Java source P1.java to ~/tmp.

- Save the following to ~/tmp/init.el:

------------------------- snip -------------------------
(require 'package)
(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/"))
(add-to-list 'package-archives
             '("gnu" . "https://elpa.gnu.org/packages/"))
(package-initialize)
(hyperbole-mode 1)
(which-function-mode 1)
------------------------- snip -------------------------

- Start emacs as

  ./src/emacs -Q -l ~/tmp/init.el ~/tmp/P1.java

  and wait for the compiler warnings to calm down.

- As Hank has recommended, forward/backward paragraph through P1.java.
  Rather soon it should hang.

And yes, it's which-function-mode which at some level inf-loops.  Maybe
the timer itself, maybe some upper layer.  If I'll find time I could try
digging into this.