Subject: map->size and MAP_INHERIT_NONE
To: None <tech-kern@netbsd.org>
From: Antti Kantee <pooka@cubical.fi>
List: tech-kern
Date: 02/09/2004 15:58:18
--+OVWeTxrbAwQuiek
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

DIAGNOSTIC kernels panic at KASSERT(map->size == 0) in uvmspace_free()
when a child process exits after a fork() with a MAP_INHERIT_NONE
entry.  This is because size bookkeeping is not done for those
entries in uvmspace_fork().

Is the attached patch okay, or are there more far-reaching consequences
related to the problem?

-- 
Antti Kantee                                      Cubical Solutions Ltd.
gsm  : +358 400 417 416                           http://www.cubical.fi/
email: antti.kantee@cubical.fi

--+OVWeTxrbAwQuiek
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="mapsize.patch"

Index: uvm_map.c
===================================================================
RCS file: /cvsroot/src/sys/uvm/uvm_map.c,v
retrieving revision 1.159
diff -u -r1.159 uvm_map.c
--- uvm_map.c	7 Feb 2004 13:22:19 -0000	1.159
+++ uvm_map.c	9 Feb 2004 13:56:58 -0000
@@ -3672,6 +3672,7 @@
 	new_map = &vm2->vm_map;		  /* XXX */
 
 	old_entry = old_map->header.next;
+	new_map->size = old_map->size;
 
 	/*
 	 * go entry-by-entry
@@ -3691,9 +3692,9 @@
 		case MAP_INHERIT_NONE:
 
 			/*
-			 * drop the mapping
+			 * drop the mapping, decrease size appropriately
 			 */
-
+			new_map->size -= old_entry->end - old_entry->start;
 			break;
 
 		case MAP_INHERIT_SHARE:
@@ -3866,7 +3867,6 @@
 		old_entry = old_entry->next;
 	}
 
-	new_map->size = old_map->size;
 	vm_map_unlock(old_map);
 
 #ifdef SYSVSHM

--+OVWeTxrbAwQuiek--