Subject: bug#6585: 23.1; Hang / CPU 100% on background interaction when in minibuffer

From: [email-masked] (Jason Cornez)
Date: Thu, 8 Jul 2010 16:19:06 +0200 (CEST)

----
Hello, I am using emacs for lisp programming.  Emacs talks to the lisp
image using sockets; the lisp runs as a subprocess.  If a background
lisp thread enters the lisp debugger, this opens a new buffer in emacs
visible in some window where it is possible to debug the problem.
Usually this all works fine.

However, if I am currently interacting with emacs in the minibuffer at
the time the lisp tries to open the new window, then emacs hangs and
consumes 100% CPU (for one core).  By "iteracting" I simply mean that
the emacs focus is in the minibuffer, such as for C-x C-f.  I don't
need to be actively typing or anything.  That is, the minibuffer is
active.

The emacs process seems to be entirely unresponsive: the cursor stops
blinking, no keyboard input is accepted, the menus do not activate,
sending commands like "emacsclient -e '(abort-recursive-edit)'" just
hang and do nothing.  The only thing I can do is kill the emacs
process.

This is very easy for me to reproduce, and I think it should not be
too hard to replicate my environment.  I also suspect that something
other than the background lisp which also would attempt to communicate
with emacs similarly while the minibuffer is active would have the
same result.  I haven't been able to come up an idea here yet.

1. I use Franz Allegro Common Lisp 8.2 and it communicates with emacs
via ELI (emacs lisp interface, also from Franz).  There is a freely
downloadable trial version of this available. www.franz.com

2. Start emacs and launch the lisp.  This is just a matter of invoking
M-x fi:common-lisp from emacs.  The Franz documentation details this
if interested.

3. At the lisp prompt:
   CL-USER(1): (mp:process-run-function "foo"
                                        (lambda ()
                                          (sleep 5) (break "foo")))

4. Immediately after hitting <Enter> above, then do C-x C-f and just
wait until the 5 seconds expire.  Emacs is now hung as I described
above.  (If you don't activate the minibuffer within 5 seconds, you'll
end up in a new buffer *background-interaction* where you can debug
the lisp process.)

Even though the steps above involve Franz ACL8.2 and ELI, I don't
think the problem is at all specific to this.  If someone can suggest
a more typical way of getting a background/child process to
communicate with emacs asynchronously, I'll be happy to try to
reproduce the problem.

Thank you,
-Jason
----

In GNU Emacs 23.1.1 (x86_64-pc-linux-gnu, GTK+ Version 2.20.0)
 of 2010-03-29 on yellow, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.10706000
configured using `configure  '--build=x86_64-linux-gnu' '--host=x86_64-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.1/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.1/leim' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=x86_64-linux-gnu' 'host_alias=x86_64-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g' 'CPPFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default-enable-multibyte-characters: t

Major mode: Apropos

Minor modes in effect:
  csv-field-index-mode: t
  desktop-save-mode: t
  display-time-mode: t
  partial-completion-mode: t
  diff-auto-refine-mode: t
  xterm-mouse-mode: t
  show-paren-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t

Recent input:
d SPC t h i s SPC c a u s e s SPC <backspace> <backspace> 
d SPC p r i n t - t o M-/ <help-echo> <backspace> <backspace> 
a s <backspace> s - x m n <backspace> l SPC t o SPC 
g e t SPC c o n f u s e d . SPC SPC A l s o SPC n e 
e d e d SPC t o SPC f i x SPC u p SPC t h e SPC d e 
b u g g i n g SPC c o d e SPC i n SPC e v e M-/ SPC 
a l o n g SPC t h e SPC w a y . <down> C-c C-c g <switch-frame> 
C-c r M-x t o g g e l <backspace> <backspace> l e - 
f o <tab> C-g M-x f o n t <tab> <tab> l <tab> m <tab> 
<return> <down> <down> <down> <down> <down> <down> 
<down> M-x f o n t - l o <tab> m <tab> <return> <up> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <up> <down> <down> <down> <down> <down> <up> 
<end> <down> <down> <down> <down> <down> <down> <down> 
<up> <left> <left> <left> <left> <left> <right> <right> 
<right> <right> <right> <right> <right> <up> <up> <up> 
<up> C-x C-f e - n <tab> <return> C-x k <return> C-x 
C-f M-p <return> <up> <up> <up> <up> <up> <end> <up> 
<up> <down> <down> <down> <switch-frame> <f5> M-x e 
m - r <tab> <M-backspace> <M-backspace> b u <tab> g 
<tab> <tab> C-g <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <help-echo> C-h a b u g <return> 
C-x o C-x 1 M-> <prior> <prior> <prior> <help-echo> 
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <menu-bar> <help-menu> <se
nd-emacs-bug-report>

Recent messages:
Expansion found in '*magit: ravenpack*'
Git finished.
package specification is `com.ravenpack.news.classification'
Quit
Font-Lock mode disabled
Font-Lock mode enabled
package specification is `com.ravenpack.news.classification'
Quit
Type C-x 1 to remove help window.  
Mark set