From owner-svn-src-head@freebsd.org Wed Nov 27 20:53:42 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B100E1B8941; Wed, 27 Nov 2019 20:53:42 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 47NY051XRrz4bSm; Wed, 27 Nov 2019 20:53:40 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id xARKrXt0081096 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 27 Nov 2019 22:53:36 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua xARKrXt0081096 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id xARKrX4x081095; Wed, 27 Nov 2019 22:53:33 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 27 Nov 2019 22:53:33 +0200 From: Konstantin Belousov To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r355146 - head/sys/kern Message-ID: <20191127205333.GL10580@kib.kiev.ua> References: <201911272033.xARKXrDm014961@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201911272033.xARKXrDm014961@repo.freebsd.org> User-Agent: Mutt/1.12.2 (2019-09-21) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-Rspamd-Queue-Id: 47NY051XRrz4bSm X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none); spf=softfail (mx1.freebsd.org: 2001:470:d5e7:1::1 is neither permitted nor denied by domain of kostikbel@gmail.com) smtp.mailfrom=kostikbel@gmail.com X-Spamd-Result: default: False [-2.00 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FREEMAIL_FROM(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; HAS_XAW(0.00)[]; TO_DN_NONE(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; IP_SCORE_FREEMAIL(0.00)[]; IP_SCORE(0.00)[ip: (-2.80), ipnet: 2001:470::/32(-4.64), asn: 6939(-3.52), country: US(-0.05)]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; FREEMAIL_ENVFROM(0.00)[gmail.com]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : No valid SPF, No valid DKIM,none] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Nov 2019 20:53:42 -0000 On Wed, Nov 27, 2019 at 08:33:53PM +0000, Konstantin Belousov wrote: > Author: kib > Date: Wed Nov 27 20:33:53 2019 > New Revision: 355146 > URL: https://svnweb.freebsd.org/changeset/base/355146 Ease the life of PTRACE_SYSCALL users when debuggee sleeps in sigsuspend(2) and sig{timed,}wait(2). If PT_TO_SCE or PT_TO_SCX were issued after the target already entered sleep in sigsuspend(2) or sigtimedwait(2), there is no debugging events generated until a relevant signal is delivered. As result, debugger hangs waiting for an event. Introduce spurious EINTR returned in that situations to help debugger to gain control earlier. [Sorry] > > Log: > Requested and tested by: kevans > Reviewed by: kevans (previous version), markj > Sponsored by: The FreeBSD Foundation > MFC after: 1 week > Differential revision: https://reviews.freebsd.org/D22546 > > Modified: > head/sys/kern/kern_sig.c > > Modified: head/sys/kern/kern_sig.c > ============================================================================== > --- head/sys/kern/kern_sig.c Wed Nov 27 20:33:49 2019 (r355145) > +++ head/sys/kern/kern_sig.c Wed Nov 27 20:33:53 2019 (r355146) > @@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > #include > #include > #include > @@ -1252,11 +1253,13 @@ kern_sigtimedwait(struct thread *td, sigset_t waitset, > int error, sig, timo, timevalid = 0; > struct timespec rts, ets, ts; > struct timeval tv; > + bool traced; > > p = td->td_proc; > error = 0; > ets.tv_sec = 0; > ets.tv_nsec = 0; > + traced = false; > > if (timeout != NULL) { > if (timeout->tv_nsec >= 0 && timeout->tv_nsec < 1000000000) { > @@ -1309,6 +1312,11 @@ kern_sigtimedwait(struct thread *td, sigset_t waitset, > timo = 0; > } > > + if (traced) { > + error = EINTR; > + break; > + } > + > error = msleep(ps, &p->p_mtx, PPAUSE|PCATCH, "sigwait", timo); > > if (timeout != NULL) { > @@ -1320,6 +1328,16 @@ kern_sigtimedwait(struct thread *td, sigset_t waitset, > error = 0; > } > } > + > + /* > + * If PTRACE_SCE or PTRACE_SCX were set after > + * userspace entered the syscall, return spurious > + * EINTR after wait was done. Only do this as last > + * resort after rechecking for possible queued signals > + * and expired timeouts. > + */ > + if (error == 0 && (p->p_ptevents & PTRACE_SYSCALL) != 0) > + traced = true; > } > > new_block = saved_mask; > @@ -1532,6 +1550,14 @@ kern_sigsuspend(struct thread *td, sigset_t mask) > has_sig += postsig(sig); > } > mtx_unlock(&p->p_sigacts->ps_mtx); > + > + /* > + * If PTRACE_SCE or PTRACE_SCX were set after > + * userspace entered the syscall, return spurious > + * EINTR. > + */ > + if ((p->p_ptevents & PTRACE_SYSCALL) != 0) > + has_sig += 1; > } > PROC_UNLOCK(p); > td->td_errno = EINTR;