locking Problem 2.0.0 on SGI

Don Badrak dbadrak at geo.census.gov
Tue Jan 19 13:56:16 GMT 1999


Hans,

On Fri, 15 Jan 1999, Herb Lewis wrote:

> > Hans Benedict wrote:
> 
> > > 3) at the same time the following appears in log.smb
> > >  [1999/01/15 17:38:11, 0] locking/shmem_sysv.c:sysv_shm_open(590)
> > >   ERROR semctl: can't IPC_STAT. Error was Bad address
> > >  [1999/01/15 17:38:11, 0] locking/locking.c:locking_init(169)
> > >   ERROR: Failed to initialise share modes!
> > >  [1999/01/15 17:38:12, 0] locking/shmem_sysv.c:sysv_shm_open(590)
> > >   ERROR semctl: can't IPC_STAT. Error was Bad address
> > >  [1999/01/15 17:38:12, 0] locking/locking.c:locking_init(169)
> > >   ERROR: Failed to initialise share modes!
> > 
> > Try stopping samba, deleting the shared memory segment and then
> > restarting samba. Use "ipcs -ma" to see the segments, and 
> > "ipcrm -m <id>" to delete sambas segment.
> 
> O.k. - after talking to the local unix guru: using cc instead of gcc
> seems to do the job! 
> 
> Thanks for your help, anyway.
> 
> Regards,
>          Hans Benedict

This is due to a bug in gcc 2.8+ (as well as egcs 1.0.2+) where the compiler
doesn't properly align structs passed by value.  Under the o32 object
format, alignment was to the right.  Under n32 (the "new" object format,
what most current stuff should be built with), it is to align to the left.

There is a FAQ about this at http://egcs.cygnus.com/faq.html#irix6n32bugs.
[It would be really nice if this were fixed, but I don't understand
compilers.  Maybe someone at SGI could lend a hand?]

My solution was to force the alignment to the left with the patch as follows.
I suppose this could probably be worked into the configuration (like
"checking for gcc's behavior with semctl").  I then define SGI_SEMUN_HACK
in CFLAGS and configure.

Don
-- 
Don Badrak <dbadrak at census.gov>              301.457.1793 work
Telecommunications Office		     301.457.4438 fax
U.S. Bureau of the Census                    301.457.1828 fax
Suitland MD, USA


-------------- next part --------------
--- source/locking/shmem_sysv.c.orig	Thu Dec 31 09:45:57 1998
+++ source/locking/shmem_sysv.c	Wed Dec 30 14:42:58 1998
@@ -24,6 +24,15 @@
 
 
 #ifdef HAVE_SYSV_IPC
+#ifdef SGI_SEMUN_HACK
+union semun_hack {
+        int val;
+        struct semid_ds *buf;
+        unsigned short *array;
+       char __dummy[5];
+};
+#define semun semun_hack
+#endif
 
 extern int DEBUGLEVEL;
 
--- source/tests/sysv_ipc.c.orig	Wed Dec 30 14:43:18 1998
+++ source/tests/sysv_ipc.c	Wed Dec 30 14:43:59 1998
@@ -20,6 +20,15 @@
 };
 #endif
 
+#ifdef SGI_SEMUN_HACK
+union semun_hack {
+	int val;
+	struct semid_ds *buf;
+	unsigned short *array;
+	char __dummy[5];
+};
+#define semun semun_hack
+#endif
 
 main()
 {


More information about the samba mailing list