From owner-freebsd-current Sat Feb 20 22:11:34 1999 Delivered-To: freebsd-current@freebsd.org Received: from janus.syracuse.net (janus.syracuse.net [205.232.47.15]) by hub.freebsd.org (Postfix) with ESMTP id 49D7211A92 for ; Sat, 20 Feb 1999 22:11:15 -0800 (PST) (envelope-from green@unixhelp.org) Received: from localhost (green@localhost) by janus.syracuse.net (8.8.8/8.8.7) with ESMTP id WAA17528 for ; Sat, 20 Feb 1999 22:48:04 -0500 (EST) Date: Sat, 20 Feb 1999 22:48:04 -0500 (EST) From: Brian Feldman X-Sender: green@janus.syracuse.net To: current@freebsd.org Subject: one SysV bug/fix, how many more Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Two things: 1. I've been looking at sysv_shm.c, and shouldn't there be a ton of splvm()ing going on which isn't? It seems that there are quite a few race conditions that never showed up before because there was no support for sharing certain parts of proc (p_vmspace etc.) For that matter, does any of kern_exit.c:exit1() need to be spl()d? It sure seems like it to me. Along with other parts of kern_exit.c, and many other things having to do with refcnt's. Is it just my paranoia, or have I got this spl concept correct? 2. I sent a previous message, but got no reply at all; the patch included follows here, and was made to fix a bug where non-removeable shm segments existed. --- src/sys/kern/sysv_shm.c.old Sat Feb 20 11:36:15 1999 +++ src/sys/kern/sysv_shm.c Sat Feb 20 11:46:19 1999 @@ -596,10 +596,13 @@ shmmap_s = (struct shmmap_state *)p->p_vmspace->vm_shm; for (i = 0; i < shminfo.shmseg; i++, shmmap_s++) - if (shmmap_s->shmid != -1) + if (shmmap_s->shmid != -1 && + --shmsegs[IPCID_TO_IX(shmmap_s->shmid)].shm_nattch < 1) shm_delete_mapping(p, shmmap_s); - free((caddr_t)p->p_vmspace->vm_shm, M_SHM); - p->p_vmspace->vm_shm = NULL; + if (p->p_vmspace->vm_refcnt == 1) { + free((caddr_t)p->p_vmspace->vm_shm, M_SHM); + p->p_vmspace->vm_shm = NULL; + } } void --- src/sys/kern/kern_exit.c.old Sat Feb 20 11:36:02 1999 +++ src/sys/kern/kern_exit.c Sat Feb 20 11:46:22 1999 @@ -206,6 +206,10 @@ /* The next two chunks should probably be moved to vmspace_exit. */ vm = p->p_vmspace; + + if (vm->vm_shm) + shmexit(p); + /* * Release user portion of address space. * This releases references to vnodes, @@ -215,8 +219,6 @@ * may be mapped within that space also. */ if (vm->vm_refcnt == 1) { - if (vm->vm_shm) - shmexit(p); pmap_remove_pages(vmspace_pmap(vm), VM_MIN_ADDRESS, VM_MAXUSER_ADDRESS); (void) vm_map_remove(&vm->vm_map, VM_MIN_ADDRESS, Brian Feldman _ __ ___ ___ ___ green@unixhelp.org _ __ ___ | _ ) __| \ http://www.freebsd.org/ _ __ ___ ____ | _ \__ \ |) | FreeBSD: The Power to Serve! _ __ ___ ____ _____ |___/___/___/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message