From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18518 invoked by alias); 11 Aug 2015 15:07:48 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 36104 Received: (qmail 26156 invoked from network); 11 Aug 2015 15:07:47 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.0 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=xl1hva6ltVS8OtzRzw6TZIV/opAYCdAWuyqiEqVmGss=; b=c3Taey6oy0cwx2dACYcHTfZmiDQdQP+cBPCnby+YAIlSYjDFWtK2RHILhjhC40j0VN SD1j3uFVyrJdhVgGKtdYB+1TasbGhjsgvXp+5tvPTssRSdHwNzkNMQCWi0t8sgiF5jEO lzRQCAFrK2hXCs8yfP4LxlyhCrZqWEw8XcPJmmOYC2AnCHU01yED9cHn/DZnXuHLhqV3 9bE1aAfG3CeU4dPSexP5LLOD/qefrdCxKEDrcPMQiJRB+HdFD6YUyMzVuHxMBLgVDCR2 AtiXNJDsl72tF35Tcj79d9qqS25becKU2XxpQL6WHbeIzvCJjpwz9CcCBH+LjAIehVzZ P2jA== X-Gm-Message-State: ALoCoQkHfLfz9s7Uh4MfHcoCRDs0I0E0iHSzLVlirSJsCWkukDxf2nwA4DvZsr2you0dVgPaaXPM X-Received: by 10.182.246.41 with SMTP id xt9mr25830350obc.55.1439305665711; Tue, 11 Aug 2015 08:07:45 -0700 (PDT) From: Bart Schaefer Message-Id: <150811080742.ZM27810@torch.brasslantern.com> Date: Tue, 11 Aug 2015 08:07:42 -0700 In-Reply-To: Comments: In reply to Mathias Fredriksson "Re: Deadlock when receiving kill-signal from child process" (Aug 11, 3:17pm) References: <150803085228.ZM24837@torch.brasslantern.com> <150803135818.ZM24977@torch.brasslantern.com> <150804235400.ZM9958@torch.brasslantern.com> <150805085258.ZM17673@torch.brasslantern.com> <150805115249.ZM7158@torch.brasslantern.com> <150805132014.ZM7746@torch.brasslantern.com> <150805220656.ZM18545@torch.brasslantern.com> <150806085451.ZM402@torch.brasslantern.com> <150806223906.ZM17762@torch.brasslantern.com> <150810123445.ZM1612@torch.brasslantern.com> <150810175343.ZM24452@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: Deadlock when receiving kill-signal from child process MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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