From Tor.Egge@idi.ntnu.no  Fri Apr 18 16:40:48 1997
Received: from pat.idt.unit.no (0@pat.idt.unit.no [129.241.103.5])
          by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id QAA13822
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 18 Apr 1997 16:40:44 -0700 (PDT)
Received: from ikke.idt.unit.no (tegge@ikke.idt.unit.no [129.241.111.65])
	by pat.idt.unit.no (8.8.5/8.8.5) with ESMTP id BAA20254
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 19 Apr 1997 01:40:32 +0200 (MET DST)
Received: (from tegge@localhost)
	by ikke.idt.unit.no (8.8.5/8.8.5) id BAA00843;
	Sat, 19 Apr 1997 01:40:32 +0200 (MET DST)
Message-Id: <199704182340.BAA00843@ikke.idt.unit.no>
Date: Sat, 19 Apr 1997 01:40:32 +0200 (MET DST)
From: Tor Egge <Tor.Egge@idi.ntnu.no>
Reply-To: Tor.Egge@idi.ntnu.no
To: FreeBSD-gnats-submit@freebsd.org
Subject: using gdb may cause hanging processes.
X-Send-Pr-Version: 3.2

>Number:         3327
>Category:       kern
>Synopsis:       using gdb may cause hanging processes.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Apr 18 16:50:03 PDT 1997
>Closed-Date:    Sat Dec 12 18:16:30 PST 1998
>Last-Modified:  Sat Dec 12 18:17:27 PST 1998
>Originator:     Tor Egge
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
Norwegian University of Science and Technology, Trondheim, Norway
>Environment:

FreeBSD ikke.idt.unit.no 3.0-CURRENT FreeBSD 3.0-CURRENT #2: Sat Apr 19 00:20:25 MET DST 1997     root@ikke.idt.unit.no:/usr/src/sys/compile/TEGGE  i386


>Description:

	When debugging a process, gdb sometimes gives a message of
	the form
	
		Cannot insert breakpoint 2:
		Error accessing memory address 0x25240: Bad address.

	After this, the process is stuck.

	Looking at the kernel with gdb -k /kernel /dev/mem, 
	showed the debugged process not being able to exit,
	due to a shared lock on a vm map blocking the
	removal of the vm map.

	"ps ax" may hang waiting for an exclusive lock
	on the vm map (due to a call to vm_fault)

>How-To-Repeat:

	Use gdb, and set some breakpoints.

>Fix:
	
	Unlock the vm map if vm_page_lookup fails.


Index: procfs_mem.c
===================================================================
RCS file: /home/ncvs/src/sys/miscfs/procfs/procfs_mem.c,v
retrieving revision 1.24
diff -c -r1.24 procfs_mem.c
*** procfs_mem.c	1997/04/06 02:29:31	1.24
--- procfs_mem.c	1997/04/18 22:19:31
***************
*** 206,211 ****
--- 206,213 ----
  			 */
  			object = NULL;
  
+ 			vm_map_lookup_done(tmap, out_entry);
+ 
  			break;
  		}
  
>Release-Note:
>Audit-Trail:

From: Tor Egge <Tor.Egge@idi.ntnu.no>
To: Tor.Egge@idi.ntnu.no
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: kern/3327: using gdb may cause hanging processes.
Date: Sat, 19 Apr 1997 04:05:00 +0200

 > 	When debugging a process, gdb sometimes gives a message of
 > 	the form
 > 	
 > 		Cannot insert breakpoint 2:
 > 		Error accessing memory address 0x25240: Bad address.
 > 
 > 	After this, the process is stuck.
 
 A more complete fix:
  	
 	Allow fallback to backing objects when reading.
  	Unlock the vm map if vm_page_lookup fails.
  
 
 Index: procfs_mem.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/miscfs/procfs/procfs_mem.c,v
 retrieving revision 1.24
 diff -c -r1.24 procfs_mem.c
 *** procfs_mem.c	1997/04/06 02:29:31	1.24
 --- procfs_mem.c	1997/04/19 01:49:07
 ***************
 *** 197,202 ****
 --- 197,213 ----
   		}
   
   		m = vm_page_lookup(object, pindex);
 + 
 + 		/* Allow fallback to backing objects if we are reading */
 + 
 + 		while (m == NULL && !writing && object->backing_object) {
 + 
 + 		  pindex += OFF_TO_IDX(object->backing_object_offset);
 + 		  object = object->backing_object;
 + 
 + 		  m = vm_page_lookup(object, pindex);
 + 		}
 + 
   		if (m == NULL) {
   			error = EFAULT;
   
 ***************
 *** 205,210 ****
 --- 216,223 ----
   			 * an error return on vm_map_lookup.
   			 */
   			object = NULL;
 + 
 + 			vm_map_lookup_done(tmap, out_entry);
   
   			break;
   		}
State-Changed-From-To: open->closed 
State-Changed-By: dillon 
State-Changed-When: Sat Dec 12 18:16:30 PST 1998 
State-Changed-Why:  
This bug appears to have been fixed by Tor Egge, 19-Apr-1997.  The last shown 
patch appears to be in the CVS tree.		 

-Matt 
>Unformatted:
