From owner-freebsd-current@freebsd.org Wed Jul 13 19:58:15 2016 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 58264B98FB3 for ; Wed, 13 Jul 2016 19:58:15 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-pa0-x22b.google.com (mail-pa0-x22b.google.com [IPv6:2607:f8b0:400e:c03::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 24BC81814 for ; Wed, 13 Jul 2016 19:58:15 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-pa0-x22b.google.com with SMTP id dx3so20751273pab.2 for ; Wed, 13 Jul 2016 12:58:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=CiKARB2fwx/TWOHUvBp0sH1xu9xNKG8X+4rd+ype0iY=; b=SqTmCd/SYlKAsbDyNuAIoMrwEoKyR3RYpg6txL98PUPax/w6bypvOjECV0jkAe4Qjp SJlVIe5K1Y38as5xpwewAFmP6eRCI98dJxqokuh7JUDoRyT1zxORgS6D+/4yR4vHRnGG 4wRCQIt2Jgbyz7J9Qs72bY+UBsk8sFpnLm39DXV9CdBDJubpUP1StBQZ3xz1w26WsP1C 8kc10YSUpJh3DwpOP7esVzlXWxEY6OqLurj77IPJ8P1VLzuPV+o3HV5nXRrKQtneMtLf +7yCMcqPlVuNs17cILXtNTcVvdUBoswwNDJHOALG5ULRETG7YDcLQrEMa/IVhAz4BCX2 reBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=CiKARB2fwx/TWOHUvBp0sH1xu9xNKG8X+4rd+ype0iY=; b=SOI8726DxNtZP0be7Fx29TPuCxz3F/dcou/PjYFez/pINDvpFzp4/1vCxyRkPtCnOh Aye5AcgcIE2ixzUYWqp19aR6RUNhQ7OwXY0rGHaldqFyFOftRrAkI4Qh6t9bICBkJrBw nClgfJbD1xD3+0M8FFSoLNapFaOlsxEOyQwa/u2/18eL9C2rmg6nRAaC3IF+4A+Tedga gY8nVFpiE0xCgDgJB5ESQN9hlzX3c/rAqczktxsbmF1BM6q7Cl1t1lg/ntVvZNbJj1an BYqsIVG9XTVc809lEhs07jNl6Gjf9VRYfq+oioKe/p5JZ2swiDLIFRQ/qAeL+1buN4p/ XgiQ== X-Gm-Message-State: ALyK8tKiseMRvP/RZyeAgpMfYy4PiXaf4l6FSac1Qo7pk4ENJq9iELPusnUtg/uy3gqr0g== X-Received: by 10.67.30.103 with SMTP id kd7mr12436237pad.83.1468439894711; Wed, 13 Jul 2016 12:58:14 -0700 (PDT) Received: from wkstn-mjohnston.west.isilon.com (c-76-104-201-218.hsd1.wa.comcast.net. [76.104.201.218]) by smtp.gmail.com with ESMTPSA id yo10sm6918482pab.4.2016.07.13.12.58.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jul 2016 12:58:14 -0700 (PDT) Sender: Mark Johnston Date: Wed, 13 Jul 2016 13:01:39 -0700 From: Mark Johnston To: Konstantin Belousov Cc: freebsd-current@FreeBSD.org Subject: Re: ptrace attach in multi-threaded processes Message-ID: <20160713200139.GC2066@wkstn-mjohnston.west.isilon.com> 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> <20160713164247.GA2066@wkstn-mjohnston.west.isilon.com> <20160713191947.GW38613@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160713191947.GW38613@kib.kiev.ua> User-Agent: Mutt/1.6.1 (2016-04-27) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jul 2016 19:58:15 -0000 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. > > 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.