|
From: Ashley P. <as...@qu...> - 2007-03-12 18:14:56
|
On Sat, 2007-03-10 at 12:35 +0000, Julian Seward wrote:
> I presume you're meaning 32-bit for 'word' and 64-bit for 'dword' here,
> and this is on a 32-bit target.
Yes, word=4 bytes, d(ouble)word=8 bytes.
> > Unfortunatly in practice it only seems to fix a small % of errors for us
> > because our copy routines only use dword copies for larger messages and
> > word copies for smaller messages, I'm still seeing errors of the form
> > shown if anybody can recommend a way of suppressing them properly. The
> > key thing is it's a four byte aligned/eight byte misaligned word read
> > immediately after a chunk of addressable memory and the suppressions
> > format doesn't let me specify this.
> >
> > RMS_RANK 0
> > Invalid read of size 4
> > at 0x4305C19: elan_tportTxStart (tportTx.c:299)
> > by 0x4245705: MPID_ELAN_SendContig (adi2send.c:70)
> > by 0x424566F: MPID_SendContig (adi2send.c:139)
> > by 0x4242044: MPID_SendDatatype (adi2hsend.c:66)
> > by 0x426A595: PMPI_Send (send.c:91)
> > by 0x8048F46: main (sendvector.c:94)
> > Address 0x5f0f41c is 0 bytes after a block of size 20 alloc'd
> > at 0x401B742: malloc (vg_replace_malloc.c:207)
> > by 0x42443D7: MPID_PackMessage (adi2mpack.c:37)
> > by 0x424200C: MPID_SendDatatype (adi2hsend.c:62)
> > by 0x426A595: PMPI_Send (send.c:91)
> > by 0x8048F46: main (sendvector.c:94)
>
> Um, this is a bit hard to think about without a specific example
> to prod at. Could you make one?
Assume that shm is a shared memory fifo and the process copying out
knows to read the size from the correct slot and only loads the relevant
data. In our experiance the use of a copy routine like this is
significantly faster than memcpy() in the cases we care about.
The code complains on i686 and x86_64 normally, --partial-loads-ok=yes
allows it to run cleanly on x86_64 but it still reports errors on i686.
Originally I had suppressions for the warning but then I realised that
it suppressed the case where invalid addresses were being passed to
send_data()
#include <inttypes.h>
#define ELAN_ALIGNUP(x,a) ((typeof(x))(((uintptr_t)(x) + ((a)-1)) &
(-(a)))) /* 'a' power of 2 */
uint64_t *shm;
void copy (void *dst, void *src, int size) {
if ( (int)src & 7 ) {
memcpy(dst,src,size);
return;
}
int ndwords = (ELAN_ALIGNUP(size, 8) >> 3);
int i,idx;
uint64_t *s = src;
uint64_t *d = dst;
idx = 0;
for ( i = 0 ; i < ndwords ; i++ )
d[idx++] = s[i];
}
int send_data (int idx, void *base, int size) {
shm[0] = idx;
shm[1] = size;
copy(&shm[2],base,size);
}
int main () {
shm = malloc(1024*64);
int i;
for ( i = 0 ; i < 32 ; i++ ) {
char *buf = malloc(i);
send_data(42,buf,i);
free(buf);
}
return 0;
}
|