Subject: 24.3.50; Infinite loop when closing some connections

From: Lars Magne Ingebrigtsen <[email-masked]>
Date: Mon, 12 Aug 2013 14:36:33 +0200

When reading (via tls) from pop3, Emacs hangs hard upon closing the
connection.

strace says:

[pid 18991] read(17, 0x7fff4c6ac3f0, 4096) = -1 EBADF (Bad file descriptor)
[pid 18991] read(17, 0x7fff4c6ac3f0, 4096) = -1 EBADF (Bad file descriptor)
[pid 18991] read(17, 0x7fff4c6ac3f0, 4096) = -1 EBADF (Bad file descriptor)
[pid 18991] read(17, 0x7fff4c6ac3f0, 4096) = -1 EBADF (Bad file descriptor)
[pid 18991] read(17, 0x7fff4c6ac3f0, 4096) = -1 EBADF (Bad file descriptor)
[pid 18991] read(17, 0x7fff4c6ac3f0, 4096) = -1 EBADF (Bad file descriptor)
[pid 18991] read(17, 0x7fff4c6ac3f0, 4096) = -1 EBADF (Bad file descriptor)
[pid 18991] read(17, 0x7fff4c6ac3f0, 4096) = -1 EBADF (Bad file descriptor)
[pid 18991] read(17, 0x7fff4c6ac3f0, 4096) = -1 EBADF (Bad file descriptor)

/proc shows that fd 17 no longer exists, so it's probably been closed by
Emacs, and we're then inflooping in a read on that socket, for some
reason,

The last checkin is:

fixes bug: http://debbugs.gnu.org/15035
committer: Paul Eggert <[email-masked]>
branch nick: trunk
timestamp: Mon 2013-08-12 00:12:07 -0700
message:
  Fix some fd issues when running subprocesses.

So that seems like a likely candidate.  :-)

Here's the gdb backtrace:

#0  0x00007ffff2f4718d in read () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00000000004e5086 in read (__nbytes=4096, __buf=0x7fffffffa340, __fd=21) at /usr/include/x86_64-linux-gnu/bits/unistd.h:45
#2  emacs_read (fildes=fildes@entry=21, buf=0x7fffffffa340 "+OK Logging out, messages deleted.\r\n", nbyte=4096) at sysdep.c:2300
#3  0x0000000000577820 in read_process_output (proc=proc@entry=26878253, channel=21) at process.c:4980
#4  0x000000000057c548 in wait_reading_process_output (time_limit=<optimized out>, nsecs=-1, read_kbd=read_kbd@entry=0, 
    do_display=do_display@entry=false, wait_for_cell=11969090, wait_proc=0x19a2128, just_wait_proc=0) at process.c:4435
#5  0x000000000057d541 in Faccept_process_output (process=26878253, seconds=<optimized out>, millisec=<optimized out>, 
    just_this_one=<optimized out>) at process.c:3948
#6  0x000000000053fb44 in Ffuncall (nargs=<optimized out>, args=<optimized out>) at eval.c:2864
#7  0x0000000000573b7b in exec_byte_code (bytestr=-9, vector=140737488331584, maxdepth=4096, args_template=140737488337176, 
    nargs=4611686018662268928, args=0x400000003f000000) at bytecode.c:905
#8  0x000000000053f5f1 in funcall_lambda (fun=25388357, nargs=nargs@entry=1, arg_vector=arg_vector@entry=0x7fffffffbaa0) at eval.c:3087
#9  0x000000000053f953 in Ffuncall (nargs=2, args=0x7fffffffba98) at eval.c:2914
#10 0x0000000000573b7b in exec_byte_code (bytestr=-9, vector=140737488331584, maxdepth=4096, args_template=0, nargs=4611686018662268928, 
    args=0x400000003f000000) at bytecode.c:905

In GNU Emacs 24.3.50.8 (x86_64-unknown-linux-gnu, X toolkit, Xaw scroll bars)
 of 2013-08-12 on stories
Bzr revision: 113815 [email-masked]
Windowing system distributor `The X.Org Foundation', version 11.0.11204000
System Description:	Debian GNU/Linux 7.0 (wheezy)

Important settings:
  value of $LANG: en_US
  locale-coding-system: iso-latin-1-unix
  default enable-multibyte-characters: t

Major mode: Bzr-Log-View

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t

Recent input:
C-x C-f s r <tab> e m <tab> / t r <tab> p <backspace> 
s r <tab> p r <tab> o <tab> c <tab> c <tab> <return> 
C-x v l <help-echo> M-x r e p o <tab> r <tab> b <tab> 
<return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Making completion list... [2 times]
Loading cc-langs...done
Making completion list...

Load-path shadows:
/home/larsi/src/clock.el/clock hides /home/larsi/lisp/clock
/home/larsi/src/cddb.el/expect hides /home/larsi/lisp/expect
/home/larsi/src/pvr.el/pvr hides /home/larsi/lisp/pvr
~/pgnus/contrib/vcard hides /home/larsi/lisp/vcard
/home/larsi/src/cddb.el/captitle hides /home/larsi/lisp/captitle
~/lisp/zenirc-2.112/src/zenirc-example hides /home/larsi/lisp/zenirc-example
~/pgnus/contrib/compface hides /home/larsi/src/emacs/trunk/lisp/gnus/compface

Features:
(shadow sort hashcash emacsbug message format-spec rfc822 mml mml-sec
mailabbrev gmm-utils mailheader sendmail mail-utils log-view easy-mmode
pcvs-util vc vc-dispatcher vc-bzr cc-langs cc-mode cc-fonts cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs help-mode
debug uniquify soap-client mm-decode mm-bodies mm-encode url-http tls
url-auth mail-parse rfc2231 rfc2047 rfc2045 ietf-drums url-gw url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util url-parse auth-source eieio byte-opt bytecomp
byte-compile cconv eieio-core gnus-util mm-util mail-prsvr
password-cache url-vars mailcap warnings xml ido flyspell ispell
benchmark w3m browse-url doc-view dired image-mode easymenu timezone
w3m-hist w3m-fb w3m-ems wid-edit w3m-ccl ccl w3m-favicon w3m-image
w3m-proc w3m-util cl-macs gv add-log mail-extr jka-compr cl cl-loaddefs
cl-lib time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel
x-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list
newcomment lisp-mode prog-mode register page menu-bar rfn-eshadow timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer nadvice loaddefs button faces cus-face macroexp
files text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
gfilenotify dynamic-setting system-font-setting font-render-setting
x-toolkit x multi-tty emacs)

-- 
(domestic pets only, the antidote for overdose, milk.)
  No Gnus T-Shirt for sale: http://ingebrigtsen.no/no.php
  and http://lars.ingebrigtsen.no/2013/08/twenty-years-of-september.html