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: Fri, 7 Aug 2015 03:45:35 +0300	[thread overview]
Message-ID: <CA+=GgY5BAkLceSV_Hav_mhna7M7aTLHH-WqV2EHmDRrMdqi16A@mail.gmail.com> (raw)
In-Reply-To: <150806085451.ZM402@torch.brasslantern.com>

On Thu, Aug 6, 2015 at 6:54 PM, Bart Schaefer wrote:
}
} This is the stdio thing again.  Anyone reading this familar enough with
} the POSIX or C standards to point to whether stdio is required to be
} signal-safe with pthreads?  I.e., is this our bug or someone else's?

Sadly I can't be of much assistance here, I believe you can't call
pthread mutexes from a signal handler, but that isn't whats happening
here? If I understand correctly a signal is received while a mutex
lock is (being) aquired.

}
} NO_TRAPS_ASYNC ?

Yes, my bad, typo in the email message, used the correct setopt.

}
} As with the previous dotrapargs() patch, I'm a little nervous about
} the dont_queue_signals() bits, but that's the only safe way to do
} the disabling part of signal queueing when the enabling part is not
} in local scope.

I'm not quite sure I understand what these changes do, but at least
this last patch made it a lot harder for me to have zsh lock up. I had
to leave my script running in a while true; do ...; done loop
(eventually, 30sec-10min it would hit a lock).

#0  0x00007fff8abfe72a in __sigsuspend ()
#1  0x0000000107b59287 in signal_suspend ()
#2  0x0000000107b30671 in zwaitjob ()
#3  0x0000000107b304c4 in waitjobs ()
#4  0x0000000107b130e8 in execpline ()
#5  0x0000000107b122ce in execlist ()
#6  0x0000000107b120f6 in execode ()
#7  0x0000000107b15ebf in runshfunc ()
#8  0x0000000107b157f4 in doshfunc ()
#9  0x0000000107b5a70b in dotrapargs ()
#10 0x0000000107b597b2 in handletrap ()
#11 0x0000000107b590b0 in zhandler ()
#12 <signal handler called>
#13 0x00007fff82ce43a8 in ferror ()
#14 0x0000000107b2abc2 in loop ()
#15 0x0000000107b2d7e0 in zsh_main ()
#16 0x00007fff8610c5c9 in start ()

This just seems like the same mutex stuff again:

#0  0x00007fff8abfe166 in __psynch_mutexwait ()
#1  0x00007fff8e4b578a in _pthread_mutex_lock ()
#2  0x00007fff82ce5750 in fputc ()
#3  0x0000000102c20cd5 in zputs ()
#4  0x0000000102c20b3c in mb_niceformat ()
#5  0x0000000102c201cd in zwarning ()
#6  0x0000000102c20376 in zwarn ()
#7  0x0000000102c143da in wait_for_processes ()
#8  0x0000000102c140a6 in zhandler ()
#9  <signal handler called>
#10 0x00007fff8abfe72a in __sigsuspend ()

This also looks vaguely familiar but might as well post it:

#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  0x0000000101ccdeaf in zalloc ()
#6  0x0000000101cee2ca in ztrdup ()
#7  0x0000000101cf89b3 in mb_niceformat ()
#8  0x0000000101cf81cd in zwarning ()
#9  0x0000000101cf8376 in zwarn ()
#10 0x0000000101cec3da in wait_for_processes ()
#11 0x0000000101cec0a6 in zhandler ()
#12 <signal handler called>
#13 0x00007fff853aacd1 in _os_lock_spin_lock ()
#14 0x00007fff896d98d6 in szone_free_definite_size ()
#15 0x0000000101ca5874 in execlist ()
#16 0x0000000101ca50f6 in execode ()
#17 0x0000000101ca8ebf in runshfunc ()
#18 0x0000000101ca87f4 in doshfunc ()
#19 0x0000000101ced70b in dotrapargs ()
#20 0x0000000101cec7b2 in handletrap ()
#21 0x0000000101ced9ec in unqueue_traps ()
#22 0x0000000101cc372b in zwaitjob ()
#23 0x0000000101cc34c4 in waitjobs ()
#24 0x0000000101ca60e8 in execpline ()
#25 0x0000000101ca52ce in execlist ()
#26 0x0000000101ccaad0 in execwhile ()
#27 0x0000000101cac0d9 in execcmd ()
#28 0x0000000101ca5d24 in execpline ()
#29 0x0000000101ca52ce in execlist ()
#30 0x0000000101ca50f6 in execode ()
#31 0x0000000101cbdb8f in loop ()
#32 0x0000000101cc07e0 in zsh_main ()
#33 0x00007fff8610c5c9 in start ()

Bonus NO_TRAPS_ASYNC:

#0  0x00007fff8abfe72a in __sigsuspend ()
#1  0x0000000107509287 in signal_suspend ()
#2  0x00000001074e0671 in zwaitjob ()
#3  0x00000001074e04c4 in waitjobs ()
#4  0x00000001074c30e8 in execpline ()
#5  0x00000001074c22ce in execlist ()
#6  0x00000001074c20f6 in execode ()
#7  0x00000001074c5ebf in runshfunc ()
#8  0x00000001074c57f4 in doshfunc ()
#9  0x000000010750a70b in dotrapargs ()
#10 0x00000001075097b2 in handletrap ()
#11 0x00000001075090b0 in zhandler ()
#12 <signal handler called>
#13 0x00007fff8abfe97a in write$NOCANCEL ()
#14 0x00007fff82ceb9ed in _swrite ()
#15 0x00007fff82ce44a7 in __sflush ()
#16 0x00007fff82ce43f5 in fflush ()
#17 0x0000000107515376 in zwarn ()
#18 0x00000001075093da in wait_for_processes ()
#19 0x00000001075090a6 in zhandler ()
#20 <signal handler called>
#21 0x00007fff8abffa12 in sigprocmask ()


  reply	other threads:[~2015-08-07  0:46 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 [this message]
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+=GgY5BAkLceSV_Hav_mhna7M7aTLHH-WqV2EHmDRrMdqi16A@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).