current cvs segfault on Debian hppa

Eric Seppanen eds at reric.net
Thu Oct 3 07:33:03 CEST 2002


On Wed, Oct 02, 2002 at 08:47:03PM -0400, Clint Adams wrote:
> Also, compiled with 3.2.1, -O0:
> 
> Starting program: /tmp/wordhash3.2 </tmp/testfile
> 
> Program received signal SIGBUS, Bus error.
> 0x00010c0c in wordhash_insert (h=0x22010, s=0xfaf003d0 "jae at jerhard.org", n=4)
>     at wordhash.c:148
> 148         return p->buf;
> (gdb) p p
> $1 = (struct hashnode_t *) 0x3f4f9
> (gdb) p *p
> $2 = {key = 0x3f50d "jae at jerhard.org", buf = 0x3f509, next = 0x0, 
>   iter_next = 0x4ff0b}

This makes me wonder if the memory allocation in the wordhash functions 
are getting the data alignment right.  If I remember correctly, x86 allows 
you to get away with stupid things like pointers at odd addresses, while 
other architectures do not.

The pointer above has a value of 0x3f4f9, an odd address.  That makes me 
worry.

Oooh.  Look here: when we call 

hmalloc(h, sizeof(hashnode_t) + n + m);;  <-- (btw: ;; typo in code?)

where m is a string length, we're going to throw the alignment all out of 
whack and start storing unaligned structures.  Even if this isn't the 
problem in this case, I belive that dropping structures into unaligned 
locations in memory is at best poor coding and a performance hit, and at 
worst will cause bus errors on some architectures.

Someone back me up on this: if hmalloc() is returning odd addresses and 
we're laying down structures at that address, we're broken on many 
architectures, right?


For summay digest subscription: bogofilter-digest-subscribe at aotto.com



More information about the Bogofilter mailing list