From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,3b07a409d26028d3,start X-Google-Attributes: gidfee84,public From: Tom Kacvinsky Subject: Tracking down and unaligned access error Date: 1999/06/24 Message-ID: <7kud0r$jnp$1@nnrp1.deja.com>#1/1 X-Deja-AN: 493531460 X-Http-Proxy: 1.0 x32.deja.com:80 (Squid/1.1.22) for client 130.44.210.14 Organization: American Mathematical Society X-Article-Creation-Date: Thu Jun 24 22:55:28 1999 GMT Newsgroups: comp.unix.osf.osf1 X-Http-User-Agent: Mozilla/4.6 (Macintosh; U; PPC) 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 #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.