Subject: SysV SHM never removed
To: NetBSD current-users mailing list <current-users@netbsd.org>
From: Julian Coleman <J.D.Coleman@newcastle.ac.uk>
List: current-users
Date: 02/12/2000 16:04:31
I've turned the game netmaze into a package. It uses shmget().
Unfortunately, I can only run it so many times before I get the error :
shmget: Cannot allocate memory
The only way to clear this is to reboot.
With a few printf()'s in sys/kern/sysv_shm.c, I see :
shminfo.shmall is 1024 (on Sparc)
shm_committed increases by 46 each time netmaze calls shmget()
when netmaze exits, shmexit() is called, which calls shm_delete_mapping()
shm_delete_mapping() does not call shm_deallocate_segment() because the
test :
if ((--shmseg->shm_nattch <= 0) &&
(shmseg->shm_perm.mode & SHMSEG_REMOVED)) {
fails. printf()'s just before this test show :
shmseg->shm_nattch = 1 This is OK.
shmseg->shm_perm.mode = 0x980 Oops! (SHMSEG_REMOVED is 0x400.)
What is the correct fix here? Remove the check for & SHMSEG_REMOVED in
shm_delete_mapping(), or set |= SHMSEG_REMOVED in (say) shmexit(), or ...
J
PS. Tested on Atari 1.4.1, Sparc 1.4.1 and Sparc 1.4R
--
My other computer also runs NetBSD
http://www.netbsd.org/