Subject: Re: unaligned access: how to track ?
To: Chris G. Demetriou <>
From: Manuel Bouyer <>
List: port-alpha
Date: 06/07/2000 18:10:39
Ok, thanks to all who anserwed. Using gdb I've been able to track down the
offending line:
(gdb) list *0x12000288c
0x12000288c is in reset_host (statd.c:402).
397             DBT *key, *data;
398             void *ptr;
399     {
400             HostInfo *hi = data->data;
402             if (hi->monList) {
403                     hi->notifyReqd = *(time_t *) data;
404                     hi->attempts = 0;
405                     hi->monList = NULL;
406             }

So it looks like hi may be unaligned ...
data->data is a void* ("DBT" type in db.h). The db type is hash.

I think data is initialised from (in libc/db/hash/hash.c line 816):
data->data = (u_char *)hashp->cpage->page + bp[ndx + 1];

I don't know how the hash db works, but we can note the following:
HostInfo is aligned (2 int and a pointer) so they can be stored contigously.
However key->data is a string (the host name) so it may have any length.
If keys and data are mixed and stored contigously in tehe file this will
cause miss-alignemnts.

This looks like the problem is in libc/db, but I'm not sure how to fix it and
anyway I don't have the time to look at it.

Manuel Bouyer, LIP6, Universite Paris VI.