Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Jul 2016 08:25:37 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Mark Johnston <markj@FreeBSD.org>
Cc:        freebsd-current@FreeBSD.org
Subject:   Re: ptrace attach in multi-threaded processes
Message-ID:  <20160714052537.GZ38613@kib.kiev.ua>
In-Reply-To: <20160713200139.GC2066@wkstn-mjohnston.west.isilon.com>
References:  <20160712055753.GI38613@kib.kiev.ua> <20160712170502.GA71220@wkstn-mjohnston.west.isilon.com> <20160712175150.GP38613@kib.kiev.ua> <20160712182414.GC71220@wkstn-mjohnston.west.isilon.com> <20160713033036.GR38613@kib.kiev.ua> <20160713040210.GA89573@wkstn-mjohnston.west.isilon.com> <20160713045439.GT38613@kib.kiev.ua> <20160713164247.GA2066@wkstn-mjohnston.west.isilon.com> <20160713191947.GW38613@kib.kiev.ua> <20160713200139.GC2066@wkstn-mjohnston.west.isilon.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Jul 13, 2016 at 01:01:39PM -0700, Mark Johnston wrote:
> On Wed, Jul 13, 2016 at 10:19:47PM +0300, Konstantin Belousov wrote:
> > On Wed, Jul 13, 2016 at 09:42:47AM -0700, Mark Johnston wrote:
> > > I'm having trouble determining if the diff changes any userland-visible
> > > behaviour. It seems that the only potential problem with the current
> > > p_xthread handling is in stopevent(), since a thread calling stopevent()
> > > from postsig() may clear p_xthread after it was set by another thread in
> > > ptracestop(). But I also don't understand why we call stopevent(S_SIG)
> > > from both issignal() and postsig() - this would appear to stop the
> > > thread twice for the same signal.
> > You mean that the patch would not fix your issue ? Quite possible, it
> > might require some more code to 'move the torch' to next xthread, so to
> > say. When you write the test case, I will spend efforts on the working
> > patch.
> 
> I don't think this addresses my issue of the process remaining stopped
> after the PT_DETACH, but see below.
Patch tries to add some coordination to ptracestop(), I do not object
to the statement that what was done is not enough.

> 
> > 
> > That said, I do not think that we should change anything about stopevent(),
> > since this is code which is on life support.  If we cannot remove procfs
> > debugging interface, let not change it at least in incompatible ways.
> > 
> > > 
> > > With respect to the desired direction, do you agree that the SIGSTOP
> > > from PT_ATTACH should effectively be ignored if a different signal stops
> > > the process first? As I said in a previous post, it seems that the
> > > SA_STOP property of PT_ATTACH's SIGSTOP is not used in the common case,
> > > since ptracestop() will stop the process if any signal is received, and
> > > the PT_DETACH operation will typically overwrite the SIGSTOP with 0 in
> > > td_xsig.
> > Hmm, I think no, we can not make such change. Issue is, debugger
> > interface guarantees (at least for single-threaded programs it is
> > done correctly) that SIGSTOP is noted. In my opinion, it would be the
> > incompatible API change.
> 
> But this guarantee is not honoured in the single-threaded case where
> PT_ATTACH sends SIGSTOP after another signal is already pending. This
> other signal will stop the process in ptracestop(), so SIGSTOP will not
> be reported until after a PT_CONTINUE or PT_DETACH, which seems to
> violate the interface as you described it. Am I missing some reason
> that this cannot occur? If not, I'll write a test case for the
> single-threaded case first.

Please give me some initial test case, I am fine with single-threaded case.
I do not think that the mt test would be much different ?



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160714052537.GZ38613>