zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: Deadlock when receiving kill-signal from child process
Date: Tue, 11 Aug 2015 08:07:42 -0700	[thread overview]
Message-ID: <150811080742.ZM27810@torch.brasslantern.com> (raw)
In-Reply-To: <CA+=GgY6deS0W2P_W4FKMS-=_ns_gH5QqUtiTbgG3W+ZHnbNEPg@mail.gmail.com>

On Aug 11,  3:17pm, Mathias Fredriksson wrote:
}
} #0  0x00007fff8abfe72a in __sigsuspend ()
} #1  0x00000001013bc3e9 in signal_suspend ()
} #2  0x0000000101392fc1 in zwaitjob ()
} #3  0x0000000101392e0c in waitjobs ()
} #4  0x0000000101374314 in execpline ()

This looks like we're waiting for a non-existent job again.  Last time
it was the strace output that pointed to the culprit, because here the
call stack has most likely grown and shrunk several times before the
blocking waitjobs() is finally called.

execpline() already does queue_signals() around its only waitjobs(),
and zwaitjob() runs the signal queue before checking the status of
jobs, so the following is a bit of a shot in the dark, rearranging
the order in which SIGCHILD and the queues are managed.  I think it's
probably better to do it in this order anyway, I was undecided about
it when I initially made the patches.


diff --git a/Src/exec.c b/Src/exec.c
index a635c18..45f1c66 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1607,8 +1607,8 @@ execpline(Estate state, wordcode slcode, int how, int last1)
 		    !(jobtab[list_pipe_job].stat & STAT_STOPPED)) {
 		    int q = queue_signal_level();
 		    child_unblock();
-		    dont_queue_signals();
 		    child_block();
+		    dont_queue_signals();
 		    restore_queue_signals(q);
 		}
 		if (list_pipe_child &&
diff --git a/Src/jobs.c b/Src/jobs.c
index 9333488..ed647b8 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -1420,9 +1420,9 @@ zwaitjob(int job, int wait_cmd)
     int q = queue_signal_level();
     Job jn = jobtab + job;
 
-    dont_queue_signals();
     child_block();		 /* unblocked during signal_suspend() */
     queue_traps(wait_cmd);
+    dont_queue_signals();
     if (jn->procs || jn->auxprocs) { /* if any forks were done         */
 	jn->stat |= STAT_LOCKED;
 	if (jn->stat & STAT_CHANGED)
@@ -1478,9 +1478,9 @@ zwaitjob(int job, int wait_cmd)
 	pipestats[0] = lastval;
 	numpipestats = 1;
     }
+    restore_queue_signals(q);
     unqueue_traps();
     child_unblock();
-    restore_queue_signals(q);
 
     return 0;
 }

-- 
Barton E. Schaefer


  parent reply	other threads:[~2015-08-11 15:07 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-03 11:25 Mathias Fredriksson
2015-08-03 15:52 ` Bart Schaefer
2015-08-03 20:36   ` Mathias Fredriksson
2015-08-03 20:58     ` Bart Schaefer
2015-08-04 21:52       ` Mathias Fredriksson
2015-08-05  0:05         ` Mathias Fredriksson
2015-08-05  6:53         ` Bart Schaefer
2015-08-05 10:37           ` Mathias Fredriksson
2015-08-05 15:52             ` Bart Schaefer
2015-08-05 16:05               ` Mathias Fredriksson
2015-08-05 18:52                 ` Bart Schaefer
2015-08-05 19:11                   ` Mathias Fredriksson
2015-08-05 20:20                     ` Bart Schaefer
2015-08-05 21:49                       ` Mathias Fredriksson
2015-08-06  5:06                         ` Bart Schaefer
2015-08-06  8:24                           ` Mathias Fredriksson
2015-08-06 15:54                             ` Bart Schaefer
2015-08-07  0:45                               ` Mathias Fredriksson
2015-08-07  5:39                                 ` Bart Schaefer
2015-08-09 13:53                                   ` Mathias Fredriksson
2015-08-09 23:42                                     ` Bart Schaefer
2015-08-10  0:02                                       ` Mikael Magnusson
2015-08-10  0:16                                         ` Mathias Fredriksson
2015-08-10  1:47                                           ` Bart Schaefer
2015-08-10  2:02                                             ` Mikael Magnusson
2015-08-10 15:59                                               ` Bart Schaefer
2015-08-10 17:30                                                 ` Mathias Fredriksson
2015-08-10  0:36                                         ` Bart Schaefer
2015-08-10  0:29                                       ` Bart Schaefer
2015-08-10 19:34                                     ` Bart Schaefer
2015-08-10 21:17                                       ` Mathias Fredriksson
2015-08-10 22:53                                         ` Mathias Fredriksson
2015-08-11  0:53                                           ` Bart Schaefer
2015-08-11 12:17                                             ` Mathias Fredriksson
2015-08-11 14:38                                               ` Mathias Fredriksson
2015-08-11 15:07                                               ` Bart Schaefer [this message]
2015-08-11 15:22                                                 ` Mathias Fredriksson
2015-08-11  4:06                                           ` Running commands in a zpty worker Bart Schaefer
2015-08-11 13:14                                             ` Mathias Fredriksson
2015-08-11 14:35                                               ` Mathias Fredriksson
2015-08-11 14:37                                               ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=150811080742.ZM27810@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).