From owner-freebsd-dtrace@freebsd.org Sat Nov 11 20:14:51 2017 Return-Path: Delivered-To: freebsd-dtrace@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 13BFCE72DA4 for ; Sat, 11 Nov 2017 20:14:51 +0000 (UTC) (envelope-from longwitz@incore.de) Received: from dss.incore.de (dss.incore.de [195.145.1.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B66AB6D641; Sat, 11 Nov 2017 20:14:50 +0000 (UTC) (envelope-from longwitz@incore.de) Received: from inetmail.dmz (inetmail.dmz [10.3.0.3]) by dss.incore.de (Postfix) with ESMTP id B6E4315FD; Sat, 11 Nov 2017 21:14:41 +0100 (CET) X-Virus-Scanned: amavisd-new at incore.de Received: from dss.incore.de ([10.3.0.3]) by inetmail.dmz (inetmail.dmz [10.3.0.3]) (amavisd-new, port 10024) with LMTP id 3XG31TuE3IDW; Sat, 11 Nov 2017 21:14:40 +0100 (CET) Received: from mail.local.incore (fwintern.dmz [10.0.0.253]) by dss.incore.de (Postfix) with ESMTP id 062E21544; Sat, 11 Nov 2017 21:14:40 +0100 (CET) Received: from bsdmhs.longwitz (unknown [192.168.99.6]) by mail.local.incore (Postfix) with ESMTP id A718F508A2; Sat, 11 Nov 2017 21:14:39 +0100 (CET) Message-ID: <5A075A2F.1040604@incore.de> Date: Sat, 11 Nov 2017 21:14:39 +0100 From: Andreas Longwitz User-Agent: Thunderbird 2.0.0.19 (X11/20090113) MIME-Version: 1.0 To: Mark Johnston CC: "freebsd-dtrace@freebsd.org" Subject: Re: dtrace pid provider on entry == Trace/BPT trap process References: <59AE834E.1090700@incore.de> <20170905144154.GC65864@wkstn-mjohnston.west.isilon.com> <5A0195CA.2010907@incore.de> <20171111035212.GA1176@bish> In-Reply-To: <20171111035212.GA1176@bish> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Nov 2017 20:14:51 -0000 > Maybe the following is of interest for DTrace experts: >> >>>> I use FreeBSD 10.3-STABLE r317936 with updated /usr/lib/dtrace/ip.c and >>>> see an issue that in my opinion should have been solved in r269342: >>> 10.3 would be missing a number of other fixes for issues that might >>> cause the symptom you're seeing. Unfortunately, userland DTrace is not >>> very usable on FreeBSD before 11.0. >> I have repeated my looptest on a server running FreeBSD 12.0-CURRENT #0 >> r324306 with GENERIC kernel. I saw the same problem as described before >> for FreeBSD 10.3-Stable r317936: >> >> Nov 7 10:54:09 dssbkp2 kernel: pid 38041 (looptest), uid >> 1003: exited on signal 5 >> >> Further I saw following error message from dtrace: >> >> dtrace: failed to grab pid 38622: Device busy. >> >> After some minutes playing around the server crashed with >> >> panic: PHOLD of exiting process 0xfffff80004c80540 > > Sorry for the delayed reply. I think this assertion is bogus: the > process in question is already held at this point, so it can't continue > exiting anyway. I think the patch below will address this and the > SIGTRAP crashes. Could you give it a try? > > diff --git a/sys/cddl/compat/opensolaris/kern/opensolaris_proc.c b/sys/cddl/compat/opensolaris/kern/opensolaris_proc.c > index 652fa8928589..63db17199fb4 100644 > --- a/sys/cddl/compat/opensolaris/kern/opensolaris_proc.c > +++ b/sys/cddl/compat/opensolaris/kern/opensolaris_proc.c > @@ -35,9 +35,7 @@ uread(proc_t *p, void *kaddr, size_t len, uintptr_t uaddr) > { > ssize_t n; > > - PHOLD(p); > n = proc_readmem(curthread, p, uaddr, kaddr, len); > - PRELE(p); > if (n != len) > return (ENOMEM); > return (0); > @@ -48,9 +46,7 @@ uwrite(proc_t *p, void *kaddr, size_t len, uintptr_t uaddr) > { > ssize_t n; > > - PHOLD(p); > n = proc_writemem(curthread, p, uaddr, kaddr, len); > - PRELE(p); > if (n != len) > return (ENOMEM); > return (0); > diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c > index 82353cbb235d..d721270fd425 100644 > --- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c > +++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c > @@ -64,6 +64,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -1097,6 +1098,8 @@ fasttrap_tracepoint_disable(proc_t *p, fasttrap_probe_t *probe, uint_t index) > p->p_dtrace_count--; > } > > + (void)quiesce_all_cpus("fasttrap", 0); > + > /* > * Remove the probe from the hash table of active tracepoints. > */ > diff --git a/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c b/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c > index d6655a0b3c55..0364aaf55094 100644 > --- a/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c > +++ b/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c > @@ -1715,11 +1715,7 @@ fasttrap_pid_probe(struct reg *rp) > > ASSERT(i <= sizeof (scratch)); > > -#ifdef illumos > if (fasttrap_copyout(scratch, (char *)addr, i)) { > -#else > - if (uwrite(p, scratch, i, addr)) { > -#endif > fasttrap_sigtrap(p, curthread, pc); > new_pc = pc; > break; I have applied your patch, no crash, no core or error message so far. But dtrace does not exit after CTRL C. After starting looptest I enter the dtrace command and type CTRL C after some seconds: dtrace -n 'pid$target:libc.so.*::entry {@[probefunc] = count();}' -p $(pgrep looptest) dtrace: description 'pid$target:libc.so.*::entry ' matched 4068 probes ^C __vfprintf 226824 localeconv_l 226824 memset 226824 sprintf 226824 vsprintf 226824 __sfvwrite 453647 memcpy 680469 ^C^C^C^C^C^C I could not stop dtrace, it does not exit. procstat gives PID PPID PGID SID TSID THR LOGIN WCHAN EMUL COMM 28183 28031 28183 28025 28025 1 longwitz fasttrap FreeBSD ELF64 dtrace If I stop looptest, then dtrace process stops immediately too. -- Andreas Longwitz