Subject: bug#16737: Yank causes hang in v24.4.1

From: Mike Crowe <[email-masked]>
Date: Tue, 11 Nov 2014 12:37:51 +0000

> I still see it and I've been tracking the emacs-24 branch. It seems to be
> a consequence of a long lived Emacs daemon session - I.e. any given
> daemon eventually starts to timeout with x pastes. I just restart the
> daemon and it goes away. I haven't restarted X/i3 for weeks.

I'm running Debian Jessie's "GNU Emacs 24.4.1 (x86_64-pc-linux-gnu, GTK+
Version 3.14.3)" in daemon mode. I rebooted yesterday and I'm seeing this
problem today (in fact, I think I saw it late yesterday too.) I have seen
the problem in earlier Debian Jessie Emacs versions too (v24.3)

I'm also running with i3 as my window manager.

For me strace appears to show looping on select during the failed
trace. This seems to be consistent with other reports:

pselect6(16, [5 8 10 13 15], NULL, NULL, {0, 296000000}, {NULL, 8}) = 1 (in [10], left {0, 295999579})
pselect6(16, [5 8 10 13 15], NULL, NULL, {0, 296000000}, {NULL, 8}) = 1 (in [10], left {0, 295999575})
pselect6(16, [5 8 10 13 15], NULL, NULL, {0, 296000000}, {NULL, 8}) = 1 (in [10], left {0, 295999578})
pselect6(16, [5 8 10 13 15], NULL, NULL, {0, 296000000}, {NULL, 8}) = 1 (in [10], left {0, 295999580})
pselect6(16, [5 8 10 13 15], NULL, NULL, {0, 296000000}, {NULL, 8}) = 1 (in [10], left {0, 295999579})
pselect6(16, [5 8 10 13 15], NULL, NULL, {0, 296000000}, {NULL, 8}) = 1 (in [10], left {0, 295999574})
pselect6(16, [5 8 10 13 15], NULL, NULL, {0, 296000000}, {NULL, 8}) = 1 (in [10], left {0, 295999574})
pselect6(16, [5 8 10 13 15], NULL, NULL, {0, 296000000}, {NULL, 8}) = 1 (in [10], left {0, 295999572})
pselect6(16, [5 8 10 13 15], NULL, NULL, {0, 296000000}, {NULL, 8}) = 1 (in [10], left {0, 295999578})
pselect6(16, [5 8 10 13 15], NULL, NULL, {0, 296000000}, {NULL, 8}) = 1 (in [10], left {0, 295999574})

with very occasional:

--- SIGIO {si_signo=SIGIO, si_code=SI_KERNEL} ---

Eventually the timeout left reduces and I see:

pselect6(16, [5 8 10 13 15], NULL, NULL, {0, 13298}, {NULL, 8}) = 1 (in [10], left {0, 12889})
pselect6(16, [5 8 10 13 15], NULL, NULL, {0, 2342}, {NULL, 8}) = 1 (in [10], left {0, 1932})
recvmsg(10, {msg_name(0)=NULL, msg_iov(1)=[{"U\2?\336\31U\307\5\3\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\37%\3\0\0"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 1312
recvmsg(10, 0x7fff51b24d40, 0)          = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=10, events=POLLIN|POLLOUT}], 1, 4294967295) = 1 ([{fd=10, revents=POLLOUT}])
writev(10, [{"+\4\1\0", 4}, {NULL, 0}, {"", 0}], 3) = 4
poll([{fd=10, events=POLLIN}], 1, 4294967295) = 1 ([{fd=10, revents=POLLIN}])
--- SIGIO {si_signo=SIGIO, si_code=SI_KERNEL} ---
recvmsg(10, {msg_name(0)=NULL, msg_iov(1)=[{"\1\1@\336\0\0\0\0\360\271\201\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 4096}], msg_controllen=0, msg_flags=0}, 0) = 32
recvmsg(10, 0x7fff51b24cf0, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(10, 0x7fff51b24cf0, 0)          = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=10, events=POLLIN|POLLOUT}], 1, 4294967295) = 1 ([{fd=10, revents=POLLOUT}])
writev(10, [{"+\4\1\0", 4}, {NULL, 0}, {"", 0}], 3) = 4
poll([{fd=10, events=POLLIN}], 1, 4294967295) = 1 ([{fd=10, revents=POLLIN}])
--- SIGIO {si_signo=SIGIO, si_code=SI_KERNEL} ---
recvmsg(10, {msg_name(0)=NULL, msg_iov(1)=[{"\1\1A\336\0\0\0\0\360\271\201\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 4096}], msg_controllen=0, msg_flags=0}, 0) = 32
recvmsg(10, 0x7fff51b24d20, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(10, 0x7fff51b24d20, 0)          = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=10, events=POLLIN|POLLOUT}], 1, 4294967295) = 1 ([{fd=10, revents=POLLOUT}])
writev(10, [{"\30\4\6\0o\0\240\2\1\0\0\0\37\0\0\0{\2\0\0009-\307\5", 24}, {NULL, 0}, {"", 0}], 3) = 24
recvmsg(10, 0x7fff51b24c70, 0)          = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=10, events=POLLIN|POLLOUT}], 1, 4294967295) = 1 ([{fd=10, revents=POLLOUT}])
writev(10, [{"+\4\1\0", 4}, {NULL, 0}, {"", 0}], 3) = 4
poll([{fd=10, events=POLLIN}], 1, 4294967295) = 1 ([{fd=10, revents=POLLIN}])
--- SIGIO {si_signo=SIGIO, si_code=SI_KERNEL} ---

I had a go with perf record to try and capture more about what was going on
and failed.

I'll see if I can apply the suggested patch to collect more information
although I'm not sure where stderr will be going when Emacs is running in
daemon mode.

Thanks.

Mike.