From sajd@telia.com  Sun Nov 10 09:08:36 2002
Return-Path: <sajd@telia.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id CEACD37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 10 Nov 2002 09:08:36 -0800 (PST)
Received: from h14n2fls34o809.telia.com (h14n2fls34o809.telia.com [217.208.95.14])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 7270043E42
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 10 Nov 2002 09:08:35 -0800 (PST)
	(envelope-from sajd@telia.com)
Received: from darkstar.sajd.net (darkstar.sajd.net [192.168.1.11])
	by h14n2fls34o809.telia.com (8.11.6+Sun/8.11.6) with ESMTP id gAAH8Xg29537
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 10 Nov 2002 18:08:33 +0100 (MET)
Received: from darkstar.sajd.net (localhost [127.0.0.1])
	by darkstar.sajd.net (8.12.6/8.12.5) with ESMTP id gAAH8X4N002185
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 10 Nov 2002 18:08:33 +0100 (CET)
	(envelope-from root@darkstar.sajd.net)
Received: (from root@localhost)
	by darkstar.sajd.net (8.12.6/8.12.6/Submit) id gAAH8WVX002184;
	Sun, 10 Nov 2002 18:08:32 +0100 (CET)
Message-Id: <200211101708.gAAH8WVX002184@darkstar.sajd.net>
Date: Sun, 10 Nov 2002 18:08:32 +0100 (CET)
From: Pawel Worach <sajd@telia.com>
Reply-To: Pawel Worach <sajd@telia.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] truss can't truss itself
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         45193
>Category:       bin
>Synopsis:       [patch] truss(1) can't truss itself
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 10 09:10:01 PST 2002
>Closed-Date:    Tue Mar 01 10:14:44 EST 2011
>Last-Modified:  Tue Mar 01 10:14:44 EST 2011
>Originator:     Pawel Worach <sajd@telia.com>
>Release:        FreeBSD 4.7-STABLE i386
>Organization:
>Environment:
System: FreeBSD darkstar 4.7-STABLE FreeBSD 4.7-STABLE #0: Sat Nov 9 17:10:55 CET 2002 root@darkstar:/usr/obj/usr/src/sys/DARKSTAR i386

>Description:
  If you try to truss the truss process with itself it will deadlock
  like truss -p <next pid>

>How-To-Repeat:
  Figure out the next pid number (using top for example) then run truss -p <pid>
  that will make truss trace itself without any result.

>Fix:
  Patch for $FreeBSD: src/usr.bin/truss/main.c,v 1.15.2.3 2002/05/16 23:41:23 peter Exp $
  (this is what it does on SunOS)

--- main.c.orig Fri May 17 01:41:23 2002
+++ main.c      Sun Nov 10 16:44:40 2002
@@ -144,6 +144,10 @@
     switch (c) {
     case 'p':  /* specified pid */
       pid = atoi(optarg);
+      if(pid == getpid()) { /* make sure i don't trace me */
+        fprintf(stderr, "truss: attempt to grab self: %d\n", pid);
+        exit(2);
+      }
       break;
     case 'o':  /* Specified output file */
       fname = optarg;

>Release-Note:
>Audit-Trail:

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/45193: commit references a PR
Date: Tue, 26 Jun 2007 22:42:46 +0000 (UTC)

 delphij     2007-06-26 22:42:38 UTC
 
   FreeBSD src repository
 
   Modified files:
     usr.bin/truss        amd64-fbsd.c i386-fbsd.c i386-linux.c 
                          ia64-fbsd.c main.c powerpc-fbsd.c setup.c 
                          sparc64-fbsd.c 
   Log:
   MFp4: Bugfixes for truss(1):
   
    - Fix logic handling execve().  We will not be able to
      obtain information otherwise.
    - truss coredump [1].
    - truss does not work against itself [2].
   
   PR:             bin/58970 [1], bin/45193 [2]
   Submitted by:   Howard Su
   Approved by:    re (kensmith)
   
   Revision  Changes    Path
   1.8       +8 -9      src/usr.bin/truss/amd64-fbsd.c
   1.28      +7 -9      src/usr.bin/truss/i386-fbsd.c
   1.27      +10 -11    src/usr.bin/truss/i386-linux.c
   1.11      +6 -10     src/usr.bin/truss/ia64-fbsd.c
   1.45      +6 -11     src/usr.bin/truss/main.c
   1.3       +9 -10     src/usr.bin/truss/powerpc-fbsd.c
   1.24      +6 -1      src/usr.bin/truss/setup.c
   1.11      +6 -10     src/usr.bin/truss/sparc64-fbsd.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: gavin 
State-Changed-When: Tue Jan 29 14:14:12 UTC 2008 
State-Changed-Why:  
Patched in -HEAD and RELENG_7 

http://www.freebsd.org/cgi/query-pr.cgi?pr=45193 
State-Changed-From-To: patched->closed 
State-Changed-By: eadler 
State-Changed-When: Tue Mar 1 10:14:43 EST 2011 
State-Changed-Why:  
This PR is fixed in head, 8.x and 7.x, but will not be merged to 6.x now 
that that branch is unsupported, sorry 

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