From owner-freebsd-current@freebsd.org Thu Jul 14 18:12:45 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 A5954B9923A for ; Thu, 14 Jul 2016 18:12:45 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-pa0-x230.google.com (mail-pa0-x230.google.com [IPv6:2607:f8b0:400e:c03::230]) (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 6AD4A1EAB for ; Thu, 14 Jul 2016 18:12:45 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-pa0-x230.google.com with SMTP id dx3so31016708pab.2 for ; Thu, 14 Jul 2016 11:12:45 -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=MBnKKwKAAnjOsW5jiT1uvuaicBas1bIsb5bFOlMgi9s=; b=u/L6kKJl20o1aJWHSVJoWyudRFM4HNlaiiKDWA/8DXIuA7zXHgvW7OS8bHtsP2l2VL FcDXnMjvMTO95MAiFy1CjgUToRRO+uoqMAo3Iab8DMn9eHHAz7E5xBtFmZcZXD6zXviK ZvqK1IDjJA10AQ6O452+kk8mKB7l5GLBQWSz59iVYeNpMurMczX3c4++AHwIx6Rr1xbf yh2FMMOTzilVP8qzypIyyEgT9haTBNGZcLxSeokaquxN37JBKsl6pagyXPi6hIKbKzlF CmEZFfo+8MVl5c9S1uIMlx0/aqYUNbHWu/zaB+vZ7Bmyg96Gly2ERrmxD3Lx4kzkwt2Z 5qDA== 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=MBnKKwKAAnjOsW5jiT1uvuaicBas1bIsb5bFOlMgi9s=; b=jmDiarPM4aZG0C4oXVcmmEa287MktRBrLbjoMuJ4ah2/PxZsTCoiQuIKK31jqK6zhZ qVjLkL9JMZEQmOpAGH7CF/FUSRrKCuRo8XFqRI+UkxQSOC1WeKBOUtLPB2bhY4bFyOe6 5vXewYaIZxo9kZkcKKMvfcDGATyUHCOFq9uiKdICzdqOYIxGD47MoRM/7netMxIY/HOd T9Z7ZI01vPALBoECX8s5f68YfR70lps2JDtBkYp0mHJSxCOqtgnHpQEVTaw4/eq3pzhZ CVg7DfjHkg9Uhp3f6vOGwWr0wqHQQV9O9VkuSc0beB6k0SrXTbEJ06k8DhMdLbznSIrN PFRA== X-Gm-Message-State: ALyK8tKrPpQ813qYjWA9nx6f1Mv35hfaSQJCGZAIy6bLLUpHg6AsVQSXHWCoZBRqJeQvog== X-Received: by 10.66.101.101 with SMTP id ff5mr18610298pab.88.1468519964946; Thu, 14 Jul 2016 11:12:44 -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 k78sm4643227pfa.78.2016.07.14.11.12.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jul 2016 11:12:44 -0700 (PDT) Sender: Mark Johnston Date: Thu, 14 Jul 2016 11:16:05 -0700 From: Mark Johnston To: Konstantin Belousov Cc: freebsd-current@FreeBSD.org Subject: Re: ptrace attach in multi-threaded processes Message-ID: <20160714181605.GA17310@wkstn-mjohnston.west.isilon.com> References: <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> <20160714052537.GZ38613@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160714052537.GZ38613@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: Thu, 14 Jul 2016 18:12:45 -0000 On Thu, Jul 14, 2016 at 08:25:37AM +0300, Konstantin Belousov wrote: > 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: > > > 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 ? Please see the program here: https://people.freebsd.org/~markj/ptrace_stop.c It cheats a bit: it uses SIGSTOP to stop the child before sending a SIGHUP to it. However, this is just for convenience; note that PT_ATTACH will result in a call to thread_unsuspend() on the child, so PT_ATTACH's SIGSTOP will be delivered to a running process. When ptrace attaches, the child stops and WSTOPSIG(status) == SIGHUP. When ptrace detaches, the child is left stopped.