Date: Sat, 20 Feb 1999 22:48:04 -0500 (EST) From: Brian Feldman <green@unixhelp.org> To: current@freebsd.org Subject: one SysV bug/fix, how many more Message-ID: <Pine.BSF.4.05.9902202240420.17317-100000@janus.syracuse.net>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.9902202240420.17317-100000>