innd dieing with SIGBUS

Alex Kiernan alexk at demon.net
Wed Jun 13 07:51:28 UTC 2001


I've been building a Solaris package for a box we're about to roll out
& I've run into alignment problems in the md5 routines when I turn up
the optimiser. lib/endian.c is clearly supposed to try and check for
whether data must be aligned, but its failing to decide it should be.

I'm guessing the compiler is generating some 64 bit instruction, but
my Sparc assembler isn't up to the job of figuring out the generated
code.

This patch, seems to get it to do the right thing for Sun CC optimised
code, but clearly its ability to cause regression on other platforms
needs testing:

Index: endian.c
===================================================================
RCS file: /cvsroot/upstream/inn/lib/endian.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 endian.c
--- endian.c	2001/05/02 14:52:46	1.1.1.1
+++ endian.c	2001/06/13 07:48:12
@@ -67,7 +67,7 @@
 {
     /* pointers into the byte order array */
     int *intp = (int *)byte;
-    char byte[2*sizeof(unsigned long)];	/* mis-alignment buffer */
+    char byte[4*sizeof(unsigned long)];	/* mis-alignment buffer */
     unsigned long *p;	/* mis-alignment pointer */
     int i;
 
@@ -93,7 +93,7 @@
     signal(SIGSEGV, buserr);	/* some systems will generate SEGV instead! */
 
     /* mis-align our long fetches */
-    for (i=0; i < sizeof(long); ++i) {
+    for (i=0; i < sizeof byte - sizeof(long); ++i) {
 	p = (unsigned long *)(byte+i);
 	store(p, i);
 	load_and_store(p, 1);


-- 
Alex Kiernan, Principal Engineer, Development, Thus PLC


More information about the inn-workers mailing list