From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,3b07a409d26028d3 X-Google-Attributes: gidfee84,public From: Tom Kacvinsky Subject: Re: Tracking down an unaligned access error Date: 1999/06/25 Message-ID: <7l0r4r$fmo$1@nnrp1.deja.com>#1/1 X-Deja-AN: 493886035 References: <7kud0r$jnp$1@nnrp1.deja.com> X-Http-Proxy: 1.0 x40.deja.com:80 (Squid/1.1.22) for client 130.44.210.14 Organization: American Mathematical Society X-Article-Creation-Date: Fri Jun 25 21:08:51 1999 GMT Newsgroups: comp.unix.osf.osf1 X-Http-User-Agent: Mozilla/4.6 (Macintosh; U; PPC) Hi again, I think I tracked my problem down. I read the alignment section in the document located at: ftp://ftp.digital.com/pub/DEC/DECinfo/document/EC-N0736-43.ps.Z and I found out that alignment on Alpha chips is either on 4 byte or 8 byte boundaries. It turns out that the line: Target_l = (unsigned long *) (string_glyph.bits + ((v_anchor + j) * paddedW / 8) + ByteOffset); made Target_l aligned to a four byte boundary (I suppose that this may be because the expression being cast is aligned to a four byte boundary. Or am I full of it?). So of course, when accessing a pointer to an unsigned long (which I know has to aligned to a eight byte boundary), we get the unaligned access error. My question is now this: is there a way of forcing data to be aligned to eight byte boundaries? For instance, with a #pragma statement, or a compiler option? Thanks, Tom > Recently, I compiled the T1Lib library, gd library, and t1sampler > executable so that I could make GIF image samples of Type 1 fonts. > > I used gcc 2.8.1 to compile T1Lib, and DEC cc to compile the gd library > and the t1sampler executable, with debugging turned on. Not sure about > optimization defaults of the compilers. > > When I ran the t1sampler binary, I got *tons* of unaligned access > errors. Following some advice I was given, I added the following code at > the beginning of main() in t1sampler to core dump upon an unaligned > access: > > The following code when added to an OSF/1 program will cause it > to dump core on misaligned accesses. I find this the easiest > way to track them down... > > /* Begin core dump snippet */ > #include > #include > > . > . > . > > /* Put this somewhere early in startup, like beginning of main() */ > > int buf[2]; > > /* Crash on mis-aligned accesses (otherwise we can't find them!) */ > buf[0] = SSIN_UACPROC; > buf[1] = UAC_SIGBUS; > setsysinfo(SSI_NVPAIRS, buf, 1, 0, 0); > /* end core dump snippet */ > > I then used gdb to get a back trace of the calling stack, I and ended up > with the following piece of code in which the unaligned access error > occurs. The guilty line is demarcated by a --->. I am stupid right now, > but why is this causing Target_l to be no longer aligned an an eight > byte > boundary? How can I fix it? > > Thanks, > > Tom > > #ifdef T1_AA_TYPE64 > /* We compile this part only if long is 64 bits to be conform to ANSI C */ > if (T1_pad==32 && T1_byte==0){ > /* The following loop steps through the lines of the character bitmap: */ > for (j=0;jmetrics.ascent-currchar->metrics.descent;j++){ > Target_l= (unsigned long *)(string_glyph.bits +((v_anchor+j)*paddedW/8) > +ByteOffset); > /* The following loop copies the scanline of a character bitmap: */ > p_l = (unsigned long *)(currchar->bits+(char_paddedW/8*j)); > if (BitShift == 0) { > for (k=char_paddedW >> 5; k; k--) > ---> *Target_l++ |= *p_l++; > } else { > for (k=0; k < char_paddedW / 32 ; k++){ > BitBuf_l= ((T1_AA_TYPE64)(*p_l++)) << BitShift; > *Target_l++ |= BitBuf_l; > *Target_l |= BitBuf_l>>l_shift; > } /* End of for ( .. ) stepping through columns */ > } > } /* End of for( .. ) steppin' through lines of char bitmap */ > }/* end if (T1_pad==32) */ > else > #endif > > Sent via Deja.com http://www.deja.com/ > Share what you know. Learn what you don't. > Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.