From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9063 invoked by alias); 6 Aug 2015 08:25:16 -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: 36006 Received: (qmail 11351 invoked from network); 6 Aug 2015 08:25:14 -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.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=uQGsJgB9RciIvTDA7QQCB7aDS89eOThwnd2z2tpELDA=; b=KcTHN17iEutn2QqKXeb5tzdg6JJvQI+a81cnquRL/aX7ofN9ipox82dqjXV86W6/wN uNlfN0wM6Du9fUXmsEk+cdNqMhJduitfdari6KQYCjJIxjO+OjqOJ6wMjKbz+aZdDu+a oIjF+YDY7tjREPsinMWcoD5d/vC3ieUfsK1+w9WFkfGa3qtuoBcWwNRFXeMXcg5NnnEw 21356S0bobBuh2ySGxJyBUsSSL2oBIG7ThuzPW7sK2eQdluWfBABLNIEKvsEXYPkTavZ qVWZbWgpsolIyNXDcXXal8937biWa990WiHnT0ckO/RTkLPT+GR+AAy/a7w1Zf0LPC0R AI3A== X-Received: by 10.182.210.234 with SMTP id mx10mr408162obc.1.1438849510069; Thu, 06 Aug 2015 01:25:10 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <150805220656.ZM18545@torch.brasslantern.com> 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> From: Mathias Fredriksson Date: Thu, 6 Aug 2015 11:24:30 +0300 Message-ID: Subject: Re: Deadlock when receiving kill-signal from child process To: zsh-workers@zsh.org Content-Type: text/plain; charset=UTF-8 On Thu, Aug 6, 2015 at 8:06 AM, Bart Schaefer wrote: } } I played around with this a bit by hacking loop() but the effect is } that with the test script Mathais provided, most of the USR1 signals } are just thrown away (they collapse into a single call to the trap } handler). Not sure if that's actually the desired effect. I would imagine some might rely on every signal being handled, e.g. keeping a count. } } You mean disowned, I presume, since all children are by definition forked. Yes, sorry for being unclear. } } Whack-a-mole continues. Does the behavior change if you } setopt NO_TRAPS_ASYNC } ?? Heh, that's exactly what this feels like. But I don't think it changes the behavior, this is pre-patch with NO_TRAPS_ASYNC set: #0 0x00007fff8abf95da in syscall_thread_switch () #1 0x00007fff853a982d in _OSSpinLockLockSlow () #2 0x00007fff896e16d9 in szone_force_lock () #3 0x00007fff896e15e6 in _malloc_fork_prepare () #4 0x00007fff82cb8097 in fork () #5 0x00000001074b166c in zfork () #6 0x00000001074b50f9 in execcmd () #7 0x00000001074b015c in execpline () #8 0x00000001074af706 in execlist () #9 0x00000001074af52e in execode () #10 0x00000001074b3133 in runshfunc () #11 0x00000001074b2c1e in doshfunc () #12 0x00000001074f788a in dotrapargs () #13 0x00000001074f69ed in handletrap () #14 0x00000001074f62fc in zhandler () #15 #16 0x00007fff896ddfc7 in small_free_list_add_ptr () #17 0x00007fff896d9ccf in szone_free_definite_size () #18 0x00000001074e6c46 in bld_eprog () #19 0x00000001074c7c70 in loop () #20 0x00000001074caac8 in zsh_main () #21 0x00007fff8610c5c9 in start () } } Next question is how much are we slowing down the shell with all of this } signal management. By just casual observation I can't tell a difference. I guess proper benchmarks would be required. The following traces have the last patches applied (I did multiple runs to see if I could hit different states): #0 0x00007fff8abf95da in syscall_thread_switch () #1 0x00007fff853a982d in _OSSpinLockLockSlow () #2 0x00007fff896d771b in szone_malloc_should_clear () #3 0x00007fff896d7667 in malloc_zone_malloc () #4 0x00007fff896d6187 in malloc () #5 0x000000010df5deaf in zalloc () #6 0x000000010df7e2ca in ztrdup () #7 0x000000010df889b3 in mb_niceformat () #8 0x000000010df881cd in zwarning () #9 0x000000010df88376 in zwarn () #10 0x000000010df7c3da in wait_for_processes () #11 0x000000010df7c0a6 in zhandler () #12 #13 0x00007fff896dad62 in tiny_free_list_add_ptr () #14 0x00007fff896d9e7f in szone_free_definite_size () #15 0x000000010df38e63 in runshfunc () #16 0x000000010df38936 in doshfunc () #17 0x000000010df7d70b in dotrapargs () #18 0x000000010df7c7b2 in handletrap () #19 0x000000010df7c0b0 in zhandler () #20 0x000000010df36775 in execpline () #21 0x000000010df3541e in execlist () #22 0x000000010df35246 in execode () #23 0x000000010df4db8f in loop () #24 0x000000010df507e0 in zsh_main () #25 0x00007fff8610c5c9 in start () -- #0 0x00007fff8abfe166 in __psynch_mutexwait () #1 0x00007fff8e4b578a in _pthread_mutex_lock () #2 0x00007fff82ce5750 in fputc () #3 0x000000010b17ccd5 in zputs () #4 0x000000010b17cb3c in mb_niceformat () #5 0x000000010b17c1cd in zwarning () #6 0x000000010b17c376 in zwarn () #7 0x000000010b1703da in wait_for_processes () #8 0x000000010b1700a6 in zhandler () #9 #10 0x00007fff8abfe72a in __sigsuspend () #11 0x000000010b170287 in signal_suspend () #12 0x000000010b147671 in zwaitjob () #13 0x000000010b1474c4 in waitjobs () #14 0x000000010b12a238 in execpline () #15 0x000000010b12941e in execlist () #16 0x000000010b129246 in execode () #17 0x000000010b12ce4b in runshfunc () #18 0x000000010b12c936 in doshfunc () #19 0x000000010b17170b in dotrapargs () #20 0x000000010b1707b2 in handletrap () #21 0x000000010b1700b0 in zhandler () #22 #23 0x00007fff8abfe166 in __psynch_mutexwait () #24 0x00007fff8e4b578a in _pthread_mutex_lock () #25 0x00007fff82ce5750 in fputc () #26 0x000000010b17ccd5 in zputs () #27 0x000000010b17cb3c in mb_niceformat () #28 0x000000010b17c1cd in zwarning () #29 0x000000010b17c376 in zwarn () #30 0x000000010b1703da in wait_for_processes () #31 0x000000010b1700a6 in zhandler () #32 #33 0x00007fff853a9340 in OSAtomicCompareAndSwapPtrBarrier$VARIANT$mp () #34 0x00007fff8e4b5714 in _pthread_mutex_lock () #35 0x00007fff82ce43a3 in ferror () #36 0x000000010b141bc2 in loop () #37 0x000000010b1447e0 in zsh_main () #38 0x00007fff8610c5c9 in start () setopt NO_ASYNC_TRAPS: #0 0x00007fff8abf95da in syscall_thread_switch () #1 0x00007fff853a982d in _OSSpinLockLockSlow () #2 0x00007fff896d771b in szone_malloc_should_clear () #3 0x00007fff896d7667 in malloc_zone_malloc () #4 0x00007fff896d6187 in malloc () #5 0x00000001081e2eaf in zalloc () #6 0x00000001082032ca in ztrdup () #7 0x000000010820d9b3 in mb_niceformat () #8 0x000000010820d1cd in zwarning () #9 0x000000010820d376 in zwarn () #10 0x00000001082013da in wait_for_processes () #11 0x00000001082010a6 in zhandler () #12 #13 0x00007fff896da116 in szone_free_definite_size () #14 0x00000001081bde63 in runshfunc () #15 0x00000001081bd936 in doshfunc () #16 0x000000010820270b in dotrapargs () #17 0x00000001082017b2 in handletrap () #18 0x00000001082029ec in unqueue_traps () #19 0x00000001081d872b in zwaitjob () #20 0x00000001081d84c4 in waitjobs () #21 0x00000001081bb238 in execpline () #22 0x00000001081ba41e in execlist () #23 0x00000001081ba246 in execode () #24 0x00000001081d2b8f in loop () #25 0x00000001081d57e0 in zsh_main () #26 0x00007fff8610c5c9 in start () -- #0 0x00007fff8abfe72a in __sigsuspend () #1 0x000000010af61287 in signal_suspend () #2 0x000000010af38671 in zwaitjob () #3 0x000000010af384c4 in waitjobs () #4 0x000000010af1b238 in execpline () #5 0x000000010af1a41e in execlist () #6 0x000000010af1a246 in execode () #7 0x000000010af1de4b in runshfunc () #8 0x000000010af1d936 in doshfunc () #9 0x000000010af6270b in dotrapargs () #10 0x000000010af617b2 in handletrap () #11 0x000000010af610b0 in zhandler () #12 #13 0x00007fff82ce43a8 in ferror () #14 0x000000010af32bc2 in loop () #15 0x000000010af357e0 in zsh_main () #16 0x00007fff8610c5c9 in start ()