Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Jul 2016 09:42:47 -0700
From:      Mark Johnston <markj@FreeBSD.org>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        freebsd-current@FreeBSD.org
Subject:   Re: ptrace attach in multi-threaded processes
Message-ID:  <20160713164247.GA2066@wkstn-mjohnston.west.isilon.com>
In-Reply-To: <20160713045439.GT38613@kib.kiev.ua>
References:  <20160712011938.GA51319@wkstn-mjohnston.west.isilon.com> <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>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Jul 13, 2016 at 07:54:39AM +0300, Konstantin Belousov wrote:
> I finally see.  Might be something like the patch below is a step in
> the desired direction.  Idea is in the proc_next_xthread(): p_xthread
> should be set to the next thread with a pending signal.  Do you have a
> test case that demonstrates the issue ?

Not yet, I'll work on one. I've only seen this occur once in an Isilon
test cluster.

The diff makes sense to me, thanks. I'd find the code easier to read if
proc_next_xthread() was a pure function that returned the flagged
thread instead of setting p_xthread.

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.

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.



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