Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: Tom Kacvinsky <tjk@ams.org>
Subject: Re: Tracking down an unaligned access error
Date: 1999/06/25	[thread overview]
Message-ID: <7l0r4r$fmo$1@nnrp1.deja.com> (raw)
In-Reply-To: 7kud0r$jnp$1@nnrp1.deja.com

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 <sys/sysinfo.h>
> 	#include <sys/proc.h>
>
> 	.
> 	.
> 	.
>
> 	/* 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;j<currchar->metrics.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.



  reply	other threads:[~1999-06-25  4:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-24  4:00 Tracking down and unaligned access error Tom Kacvinsky
1999-06-25  4:00 ` Tom Kacvinsky [this message]
1999-06-25  4:00   ` Tracking down an " Tom Kacvinsky
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox