* Tracking down and unaligned access error
@ 1999-06-24 4:00 Tom Kacvinsky
1999-06-25 4:00 ` Tracking down an " Tom Kacvinsky
0 siblings, 1 reply; 3+ messages in thread
From: Tom Kacvinsky @ 1999-06-24 4:00 UTC (permalink / raw)
Hi,
Recently, I compile 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, anc 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Tracking down an unaligned access error
1999-06-24 4:00 Tracking down and unaligned access error Tom Kacvinsky
@ 1999-06-25 4:00 ` Tom Kacvinsky
1999-06-25 4:00 ` Tom Kacvinsky
0 siblings, 1 reply; 3+ messages in thread
From: Tom Kacvinsky @ 1999-06-25 4:00 UTC (permalink / raw)
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Tracking down an unaligned access error
1999-06-25 4:00 ` Tracking down an " Tom Kacvinsky
@ 1999-06-25 4:00 ` Tom Kacvinsky
0 siblings, 0 replies; 3+ messages in thread
From: Tom Kacvinsky @ 1999-06-25 4:00 UTC (permalink / raw)
Yeesh! You'd think that I could get the post right.
I meant a compiler option besides '-assume noaligned_objects'
Thanks again,
Tom
>
> 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?
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1999-06-25 4:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-06-24 4:00 Tracking down and unaligned access error Tom Kacvinsky
1999-06-25 4:00 ` Tracking down an " Tom Kacvinsky
1999-06-25 4:00 ` Tom Kacvinsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox