Subject: Re: bug#11403: 24.0.96; Emacs crashes when ViewMail downloads IMAP messages

From: Chong Yidong <[email-masked]>
Date: Sat, 05 May 2012 00:08:02 +0800

Konrad Hinsen <[email-masked]> writes:

> Sorry, I can't give a recipe, but this happens about twice a day
> since I use prerelease 24.0.96. The situation is always the same:
> I open a VM folder (VM = ViewMail), or I refresh an already opened
> one. VM starts downloading messages from my IMAP server, annoucing
> its progress in the minibuffer. And then Emacs crashes before VM
> as finished downloading and displaying the new messages.

I assume, from your description, that these crashes didn't happen on
24.0.95?

Off the top of my head, I don't see anything informative in the
backtrace you sent.  But if the bug has something to with process
interaction, there was only one change in process.c between 24.0.95 and
24.0.96 which could have caused this.

Could you try running with the following patch (which basically reverts
said change) and see if it makes any difference?

=== modified file 'src/process.c'
*** src/process.c	2012-04-20 06:39:29 +0000
--- src/process.c	2012-05-04 16:04:10 +0000
***************
*** 4893,4915 ****
  		 It can't hurt.  */
  	      else if (nread == -1 && errno == EIO)
  		{
! 		  struct Lisp_Process *p = XPROCESS (proc);
! 
! 		  /* Clear the descriptor now, so we only raise the
! 		     signal once.  */
! 		  FD_CLR (channel, &input_wait_mask);
! 		  FD_CLR (channel, &non_keyboard_wait_mask);
! 
! 		  if (p->pid == -2)
! 		    {
! 		      /* If the EIO occurs on a pty, sigchld_handler's
! 			 wait3() will not find the process object to
! 			 delete.  Do it here.  */
! 		      p->tick = ++process_tick;
! 		      p->status = Qfailed;
! 		    }
!                   else
! 		    kill (getpid (), SIGCHLD);
  		}
  #endif /* HAVE_PTYS */
  	      /* If we can detect process termination, don't consider the
--- 4893,4908 ----
  		 It can't hurt.  */
  	      else if (nread == -1 && errno == EIO)
  		{
!                   /* Don't do anything if only a pty, with no associated
! 		     process (bug#10933).  */
!                   if (XPROCESS (proc)->pid != -2) {
!                     /* Clear the descriptor now, so we only raise the signal
! 		       once.  */
!                     FD_CLR (channel, &input_wait_mask);
!                     FD_CLR (channel, &non_keyboard_wait_mask);
!                     
!                     kill (getpid (), SIGCHLD);
!                   }
  		}
  #endif /* HAVE_PTYS */
  	      /* If we can detect process termination, don't consider the