From nobody@FreeBSD.org  Thu Jun 14 20:04:21 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (unknown [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id F1187106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 14 Jun 2012 20:04:20 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [69.147.83.34])
	by mx1.freebsd.org (Postfix) with ESMTP id C26778FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 14 Jun 2012 20:04:20 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q5EK4Ksf067851
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 14 Jun 2012 20:04:20 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q5EK4KGE067850;
	Thu, 14 Jun 2012 20:04:20 GMT
	(envelope-from nobody)
Message-Id: <201206142004.q5EK4KGE067850@red.freebsd.org>
Date: Thu, 14 Jun 2012 20:04:20 GMT
From: Ryan Goodfellow <rgoodfel@eecs.wsu.edu>
To: freebsd-gnats-submit@FreeBSD.org
Subject: DTrace broken for simple user land program
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         169080
>Category:       kern
>Synopsis:       [dtrace] DTrace broken for simple user land program
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    markj
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jun 14 20:10:01 UTC 2012
>Closed-Date:    Sun Apr 13 20:31:16 UTC 2014
>Last-Modified:  Sun Apr 13 20:31:16 UTC 2014
>Originator:     Ryan Goodfellow
>Release:        9.0
>Organization:
Washington State University
>Environment:
FreeBSD rybsd 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Thu Jan 14 10:18:24 PDT 2012
    root@rybsd:/usr/obj/usr/src/sys/DTRACE amd64
>Description:
Today I downloaded and installed FreeBSD 9.0-RELEASE and followed the directions from <http://wiki.freebsd.org/DTrace> to get DTrace up and running. Including rebuilding and installing the world with the specified arguments.  The output of DTrace instrumenting a simple program, however, is not correct.  The program is as follows:

// test.cc
#include<cstdlib>

int main(void) {
 for(int i = 0; i < 5; i++) {
   malloc(47);
 }
}

then compiling and running DTrace as follows:

g++ test.cc -o test

dtrace -n 'pid$target::malloc:entry{ }' -c ./test


The correct output for this example is something to the tune of:

dtrace: description 'pid$target::malloc:entry' matched 2 probes
dtrace: pid 95236 has exited
CPU     ID                    FUNCTION:NAME
 0 188748                     malloc:entry 
 0 188748                     malloc:entry 
 0 188748                     malloc:entry 
 0 188748                     malloc:entry 
 0 188748                     malloc:entry 

(this from a machine with the same code running DTrace)

The DTrace session should also make an immediate exit on completion. On FreeBSD I have the following
CPU     ID                    FUNCTION:NAME
 2      42213                     malloc:entry 

and the execution does either not exit on it's own or hangs, it requires a ctrl-c.

I followed the instructions from the FreeBSD site exactly, compiling and installing the custom kernel.  I used both clang++ and g++ for compilation with the same result.  The system has even completely hung on other attempts.

Is DTrace not something that should be relied upon in FreeBSD?  I have also tried this on the latest 10-CURRENT build with the same result.

>How-To-Repeat:
Copile this:

// test.cc
#include<cstdlib>
int main(void) {
 for(int i = 0; i < 5; i++) {
   malloc(47);
 }
}

g++ test.cc -o test

Run this:

dtrace -n 'pid$target::malloc:entry{ }' -c ./test

Observe something this (you may have to use ctrl-c to get dtrace to exit:

CPU     ID                    FUNCTION:NAME
 2      42213                     malloc:entry 

Which should be more like this this (5 fired probes):

dtrace: description 'pid$target::malloc:entry' matched 2 probes
dtrace: pid 95236 has exited
CPU     ID                    FUNCTION:NAME
 0 188748                     malloc:entry 
 0 188748                     malloc:entry 
 0 188748                     malloc:entry 
 0 188748                     malloc:entry 
 0 188748                     malloc:entry 

>Fix:
Unknown

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->gnn 
Responsible-Changed-By: gnn 
Responsible-Changed-When: Wed Jul 4 00:56:58 UTC 2012 
Responsible-Changed-Why:  
Take another DTrace bug. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169080 
State-Changed-From-To: open->feedback 
State-Changed-By: markj 
State-Changed-When: Sun Dec 29 18:32:38 UTC 2013 
State-Changed-Why:  
Cannot reproduce on CURRENT. Waiting for submitter feedback (see the 
followup). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169080 
Responsible-Changed-From-To: gnn->markj 
Responsible-Changed-By: markj 
Responsible-Changed-When: Sun Dec 29 18:32:50 UTC 2013 
Responsible-Changed-Why:  
Track. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169080 

From: Mark Johnston <markj@freebsd.org>
To: bug-followup@FreeBSD.org, rgoodfel@eecs.wsu.edu
Cc:  
Subject: Re: kern/169080: [dtrace] DTrace broken for simple user land program
Date: Sun, 29 Dec 2013 13:31:53 -0500

 I cannot reproduce this on FreeBSD-CURRENT. Quite a few problems in
 DTrace and libproc have been fixed in the last several months; would
 you be able to retry on CURRENT. 10.0 will not have some of these
 fixes, but they will be available in 10.1.
 
 -Mark
State-Changed-From-To: feedback->closed 
State-Changed-By: markj 
State-Changed-When: Sun Apr 13 20:31:15 UTC 2014 
State-Changed-Why:  
The submitter and I verified that the test program works on head and 
stable/10. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169080 
>Unformatted:
