From cole@jnx.com  Fri May  2 16:05:54 1997
Received: from red.jnx.com (red.jnx.com [208.197.169.254])
          by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id QAA28986
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 2 May 1997 16:05:54 -0700 (PDT)
Received: from dakine.jnx.com (dakine.jnx.com [208.197.169.244])
	by red.jnx.com (8.8.5/8.8.5) with ESMTP id QAA11068;
	Fri, 2 May 1997 16:05:22 -0700 (PDT)
Received: (from cole@localhost) by dakine.jnx.com (8.7.6/8.7.3) id QAA12475; Fri, 2 May 1997 16:05:21 -0700 (PDT)
Message-Id: <199705022305.QAA12475@dakine.jnx.com>
Date: Fri, 2 May 1997 16:05:21 -0700 (PDT)
From: Bruce Cole <cole@jnx.com>
Reply-To: cole@jnx.com
To: FreeBSD-gnats-submit@freebsd.org
Cc: cole@jnx.com
Subject: gdb(ptrace?) cause create/modify times on executable to change
X-Send-Pr-Version: 3.2

>Number:         3475
>Category:       kern
>Synopsis:       gdb(ptrace?) cause create/modify times on executable to change
>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:   Fri May  2 16:10:02 PDT 1997
>Closed-Date:    Mon Sep 21 18:32:07 PDT 1998
>Last-Modified:  Mon Sep 21 18:33:49 PDT 1998
>Originator:     Bruce Cole
>Release:        FreeBSD 2.200-Juniper i386
>Organization:
Juniper Networks
>Environment:

        Problem is seen on kernels based upon 2.2.1-RELEASE.

>Description:

        Gdb'ing an executable and setting a breakpoint often results in
        the creation and modification times on the gdb'd executable changing.
        When you rerun the executable from under gdb, gdb complains that the
        executable has changed (however it hasn't really at all).  When
        the executable is NFS mounted, this can result in the program dying
        due to alleged text segment modification.

	The problem happens even when the user does not have write access
	to the executable that is being debugged!

        It seems that something is going wrong in the kernel.  When ptrace()
        goes to set a breakpoint in the executable, I'd expect a copy on
        write operation to occur, and for the executable's 
	creation/modification dates to remain untouched.

>How-To-Repeat:

Script started on Fri May  2 15:57:12 1997
dakine(cole): cat >! test.c
main()
{
	printf("Hello world\n");
}
dakine(cole): cc -g -o test test.c
dakine(cole): ls -l test
-rwxrwxr-x  1 cole  cole  9790 May  2 15:57 test*
dakine(cole): date
Fri May 02 03:58:00 PM
dakine(cole): gdb test
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.16 (i386-unknown-freebsd3.0), 
Copyright 1996 Free Software Foundation, Inc...
(gdb) break main
Breakpoint 1 at 0x1598: file test.c, line 3.
(gdb) run
Starting program: /usr/home/cole/test/test -N -f ~/conf/com.conf

Breakpoint 1, main () at test.c:3
3		printf("Hello world\n");
(gdb) 
Suspended
dakine(cole): ls -l test
-rwxrwxr-x  1 cole  cole  9790 May  2 15:57 test*
dakine(cole): sync
dakine(cole): ls -l test
-rwxrwxr-x  1 cole  cole  9790 May  2 15:58 test*
dakine(cole): fg
gdb test
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
`/usr/home/cole/test/test' has changed; re-reading symbols.
Starting program: /usr/home/cole/test/test -N -f ~/conf/com.conf

Breakpoint 1, main () at test.c:3
3		printf("Hello world\n");
(gdb) quit
The program is running.  Quit anyway (and kill it)? (y or n) y
dakine(cole): ^Dexit

Script done on Fri May  2 15:58:20 1997


>Fix:
	
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: jdp 
State-Changed-When: Mon Sep 21 18:32:07 PDT 1998 
State-Changed-Why:  
Fixed in 2.2-stable by revision 1.20.2.2 of procfs_mem.c and related 
changes to several other files. 
>Unformatted:
