zsh-workers
 help / color / mirror / code / Atom feed
From: Mathias Fredriksson <mafredri@gmail.com>
To: zsh-workers@zsh.org
Subject: Re: Deadlock when receiving kill-signal from child process
Date: Thu, 6 Aug 2015 11:24:30 +0300	[thread overview]
Message-ID: <CA+=GgY5xEojBVRpKKZp-svZStp-s4=N10Xz2n0=s8SKjUpbNwg@mail.gmail.com> (raw)
In-Reply-To: <150805220656.ZM18545@torch.brasslantern.com>

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 <signal handler called>
#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 <signal handler called>
#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  <signal handler called>
#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 <signal handler called>
#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 <signal handler called>
#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 <signal handler called>
#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 <signal handler called>
#13 0x00007fff82ce43a8 in ferror ()
#14 0x000000010af32bc2 in loop ()
#15 0x000000010af357e0 in zsh_main ()
#16 0x00007fff8610c5c9 in start ()


  reply	other threads:[~2015-08-06  8:25 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 [this message]
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
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='CA+=GgY5xEojBVRpKKZp-svZStp-s4=N10Xz2n0=s8SKjUpbNwg@mail.gmail.com' \
    --to=mafredri@gmail.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).