Hi!

I think I found a bug in shmem/unix/shm.c around line 317.

In line 302, the file is created with the flags APR_CREATE | APR_EXCL (among others), and in line 316 shmget is called with IPC_CREAT | IPC_EXCL, which fails because the first call already created the file. It seems to work without IPC_CREAT, but I am no expert on shmget and am not sure if this is the way to fix it.

The attached patch takes out both the IPC_CREAT and IPC_EXCL flags. I wasn't sure whether to keep IPC_CREAT. It might make a difference if someone else is messing with the file at the same time, so I decided to prefer failing due to a missing file over continuing with potentially undefined results.

Dirk
Index: shmem/unix/shm.c
===================================================================
--- shmem/unix/shm.c    (revision 376901)
+++ shmem/unix/shm.c    (working copy)
@@ -314,7 +314,7 @@
         }
 
         if ((new_m->shmid = shmget(shmkey, new_m->realsize,
-                                   SHM_R | SHM_W | IPC_CREAT | IPC_EXCL)) < 0) 
{
+                                   SHM_R | SHM_W)) < 0) {
             return errno;
         }
 

Reply via email to