Subject: bug#16737: Emacs bug #16737: Possible patch

From: Mike Crowe <[email-masked]>
Date: Wed, 15 Jul 2015 19:36:38 +0100

On Thursday 09 July 2015 at 13:44:15 +0100, Mike Crowe wrote:
> On Wednesday 08 July 2015 at 21:54:13 +0100, Mike Crowe wrote:
> > Thanks to Alan's reproduction recipe in message #158 I've been able to
> > do a bit of digging.
> > 
> > From what I can determine pselect is continuously being woken up due
> > to activity on the X file descriptor (this can be seen in message #70)
> > yet pending_signals never gets set so unblock_input_to never calls
> > process_pending_signals so xgselect just goes round and round until
> > the timeout time is reached. :(
> > 
> > I suspected that SIGIO was left being incorrectly blocked but I
> > haven't been able to find any evidence for that yet.
> 
> I think that suspicion is correct.
> 
> The massive paste in the terminal causes
> keyboard.c:kbd_buffer_store_buffered_event to call ignore_sigio() but the only
> place I could find that sets the handler for SIGIO is init_keyboard so
> noone ever re-enables the SIGIO signal handler. :(
> 
> It appears that keyboard.c:kbd_buffer_get_event used to re-enable the
> signal handler but that was removed in
> 4d7e6e51dd4acecff466a28d958c50f34fc130b8.
> 
> I tried reinstating enabling the signal handler with this patch
> against master and I can no longer reproduce the problem when
> following with Alan's recipe.

I've sent this patch to the emacs-devel list[1] but it didn't yield any
response. I've been running with it for a week now. The problem has not
recurred and I haven't seen any downsides.

(For those I've CC'd on this here's a handy link to the entire discussion:
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16737 )

Mike.

[1] https://lists.gnu.org/archive/html/emacs-devel/2015-07/msg00106.html