Operating System - HP-UX
1752801 Members
5618 Online
108789 Solutions
New Discussion

bus error due to unaligned data

 
Sruthi P
Occasional Contributor

bus error due to unaligned data

I am porting our application to 64-bit on a HP-ia64 11.23 machine.

My application crashes with a bus error due to unaligned data access problem.
I googled it out and was asked to use the +ubytes compiler option. aCC does not recognize it as a valid option.

The link given in the stack trace pointed to a document where in the comments section +u1 flag is mentioned
// Undefined behavior
// Likely Abort unless compiled with +u1
// The address of a reference (*ip) is
// assigned to an int pointer.

I recompiled my application using the +u1 flag but it dosent seem to be working. My application still crashes with a bus error.
Which flag should I use.

Any help is appreciated.

Thanks and Regards
Sruthi
1 REPLY 1
Dennis Handly
Acclaimed Contributor

Re: bus error due to unaligned data

>+ubytes compiler option. aCC does not recognize it as a valid option.

"bytes" above is a meta symbol for the alignment value, 1, 2, 4.

If you use +u1, that doesn't cover code compiled without that option. You need to call allow_unaligned_data_access:
http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/Online_Help/pragmas.htm#pragma-pack-ex4

>The link given in the stack trace pointed to a document where in the comments section +u1 flag is mentioned

Please include your stack trace.