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: Sun, 9 Aug 2015 16:53:52 +0300	[thread overview]
Message-ID: <CA+=GgY4+utmAzyYyBn1wQy1BhFcrzk+DiN+FcqYOpUdrSHhbGg@mail.gmail.com> (raw)
In-Reply-To: <150806223906.ZM17762@torch.brasslantern.com>

First off, great work on the last patch (zsh-workers 36022) Bart! I've
been testing now with the latest git master and applied said patch on
top. At first I thought there were absolutely no more deadlocks, but I
managed to repeatedly produce one (when _not_ disowning the child
processes). I'm wondering if I'm not getting the complete picture
though since there are some "in ?? ()" also in there (I did build with
debugging enabled though).

My configure options for reference:

--enable-cap
--enable-multibyte
--enable-maildir-support
--with-tcsetpgrp
--enable-zsh-debug
--enable-zsh-mem-debug
--enable-zsh-mem-warning
--enable-zsh-secure-free
--enable-zsh-hash-debug

Trace:

#0  0x00007fff8abf95da in syscall_thread_switch ()
#1  0x00007fff853a982d in _OSSpinLockLockSlow ()
#2  0x00007fff896e1635 in szone_force_lock ()
#3  0x00007fff896e15e6 in _malloc_fork_prepare ()
#4  0x00007fff82cb8097 in fork ()
#5  0x0000000105d3f960 in get_match_ret ()
#6  0x0000000105d45463 in savehistfile ()
#7  0x0000000105d42b4f in iaddtoline ()
#8  0x0000000105d3d69f in gmatchcmp ()
#9  0x0000000105d3c6ce in qualisdev ()
#10 0x0000000105d3bff5 in zglob ()
#11 0x0000000105d423e8 in histstrcmp ()
#12 0x0000000105d41db3 in printreswdnode ()
#13 0x0000000105dba726 in ?? ()
#14 0x0000000105dbac89 in ?? ()
#15 0x0000000105db91ef in ?? ()
#16 0x0000000105db8839 in ?? ()
#17 <signal handler called>
#18 0x00007fff896db4fe in tiny_free_list_remove_ptr ()
#19 0x00007fff896d9b2e in szone_free_definite_size ()
#20 0x0000000105d82ef6 in getredirs ()
#21 0x0000000105d70231 in patmatch ()
#22 0x0000000105d6fd7b in patmatch ()
#23 0x0000000105d6f8d7 in pattryrefs ()
#24 0x0000000105d6e105 in patcompile ()
#25 0x0000000105db8d7d in ?? ()
#26 0x0000000105db85bf in ?? ()
#27 0x0000000105d3cf36 in scanner ()
#28 0x0000000105d7bf51 in paramsubst ()
#29 0x0000000105d47389 in chrealpath ()
#30 0x0000000105d42b4f in iaddtoline ()
#31 0x0000000105d3d69f in gmatchcmp ()
#32 0x0000000105d3c6ce in qualisdev ()
#33 0x0000000105d7ce45 in paramsubst ()
#34 0x0000000105d47389 in chrealpath ()
#35 0x0000000105d42b4f in iaddtoline ()
#36 0x0000000105d3d69f in gmatchcmp ()
#37 0x0000000105d3c6ce in qualisdev ()
#38 0x0000000105d3bff5 in zglob ()
#39 0x0000000105d66d6a in histcharssetfn ()
#40 0x0000000105d6b0f2 in par_cond_2 ()
#41 0x0000000105d1e9b2 in _mh_execute_header ()
#42 0x00007fff8610c5c9 in start ()

On Fri, Aug 7, 2015 at 8:39 AM, Bart Schaefer wrote:
}
} Specifially ferror() is attempting to acquire a mutex lock when the
} signal arrives, and then the handler calls fputc() which tries to
} acquire the same lock, and: clunk.

Aha, ok.

}
} So anytime I find myself using dont_queue_signals() I worry that there
} is a calling scope reason avoid signal handlers.  On the other hand,
} if it's safe to run shell code at all (e.g., runshfunc()), it should
} also be safe to run signal traps.

Thanks for the thorough walkthrough, I understand it a bit better now!

}
} The stack must go further than this?  What called __sigsuspend() ?

Actually that is all that I got out from gdb, I'll try to dig deeper
somehow (if it's possible) next time it happens.

}
} This trace must also go further?  The part shown is calling a handler
} while during fflush() in a previous handler, but the trace doesn't
} go back far enough to see where the first handler was called.

Same as previous, this was all that I got out from gdb.


  reply	other threads:[~2015-08-09 13:54 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 [this message]
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+=GgY4+utmAzyYyBn1wQy1BhFcrzk+DiN+FcqYOpUdrSHhbGg@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).