Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: Tom Kacvinsky <tjk@ams.org>
Subject: Tracking down and unaligned access error
Date: 1999/06/24	[thread overview]
Message-ID: <7kud0r$jnp$1@nnrp1.deja.com> (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.



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

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-24  4:00 Tom Kacvinsky [this message]
1999-06-25  4:00 ` Tracking down an unaligned access error Tom Kacvinsky
1999-06-25  4:00   ` 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