Operating System - HP-UX
1752809 Members
6076 Online
108789 Solutions
New Discussion

Invalid address alignment - Program received signal SIGBUS, Bus error

 
bhanu926
Occasional Visitor

Invalid address alignment - Program received signal SIGBUS, Bus error

Hi Team,

 

I am running building our code on HP-UX  B.11.31 U ia64. This code works on all platfroms except this and I recieve the below error.

 

 

Program received signal SIGBUS, Bus error
si_code: 1 - BUS_ADRALN - Invalid address alignment. Please refer to the following link that helps in handling unaligned datewhelp0610/pragmas.htm#pragma-pack-ex3.
0x20000000745f44f0:1 in BaseStatement::execute ()
at base/source/baseexec.cpp:1102
(gdb) bt
#0 0x20000000745f44f0:1 in BaseStatement::execute ()
at base/source/baseexec.cpp:1102
#1 0x20000000745f00e0:0 in BaseStatement::SQLExecute ()
at base/source/baseexec.cpp:194
#2 0x20000000747a9c50:0 in SQLExecute () at ./base/include/comnapi.cpp:771
#3 0x2000000074b65990:0 in SQLExecute () at dm/dm/dmexec.c:389
#4 0x20000000758437d0:0 in CPtHDBPr::ExecPreparedUpdate ()
at dbprim/cpthdbpr.cpp:2285
#5 0x4004140:0 in main () at test1.cpp:45
(gdb) disas $pc-16*4 $pc+16*4
Dump of assembler code from 0x20000000745f44b0:0 to 0x20000000745f4530:0:
;;; File: base/source/baseexec.cpp
;;; Line: 1101
0x20000000745f44b0:0 <BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)+0x1df0>:
addp4 r14=224,r32;; M,MI
0x20000000745f44b0:1 <BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)+0x1df1>: ld4
0x20000000745f44b0:2 <BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)+0x1df2>: cmp4.eq.unc
0x20000000745f44c0:0 <BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)+0x1e00>:
ld1.a ret2=[ret1];; M,MI
0x20000000745f44c0:1 <BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)+0x1e01>: ld4.s
0x20000000745f44c0:2 <BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)+0x1e02>: extr.u
0x20000000745f44d0:0 <BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)+0x1e10>:
addp4 ret3=172,ret3;; M,MI,
---Type <return> to continue, or q <return> to quit---
0x20000000745f44d0:1 <BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)+0x1e11>: ld4
0x20000000745f44d0:2 <BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)+0x1e12>: adds
0x20000000745f44e0:0 <BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)+0x1e20>:
cmp4.eq.unc p7=r0,r16 MMB,
0x20000000745f44e0:1 <BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)+0x1e21>: addp4
0x20000000745f44e0:2 <BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)+0x1e22>:
(p7) br.cond.dpnt.many _ZN13BaseStatement7executeEtPtS0_+0x1e40;;
;;; Line: 1102
0x20000000745f44f0:0 <BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)+0x1e30>:
chk.s.m r15,_ZN13BaseStatement7executeEtPtS0_+0x2e10 MMI,
0x20000000745f44f0:1 <BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)+0x1e31>: st4
0x20000000745f44f0:2 <BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)+0x1e32>: nop.i
;;; Line: 1110
---Type <return> to continue, or q <return> to quit---
0x20000000745f4500:0 <BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)+0x1e40>:
chk.a.clr ret2,_ZN13BaseStatement7executeEtPtS0_+0x2df0 MMI
0x20000000745f4500:1 <BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)+0x1e41>: cmp4.eq.unc
0x20000000745f4500:2 <BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)+0x1e42>: nop.i
0x20000000745f4510:0 <BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)+0x1e50>:
nop.m 0x0 MBB
0x20000000745f4510:1 <BaseStatement::execute(unsigned short,unsigned short*,unsi
(p7) br.cond.dpnt.many _ZN13BaseStatement7executeEtPtS0_+0x1e60
0x20000000745f4510:2 <BaseStatement::execute(unsigned short,unsigned short*,unsi
(p6) br.cond.dpnt.many _ZN13BaseStatement7executeEtPtS0_+0x1f70;;
;;; Line: 1140
0x20000000745f4520:0 <BaseStatement::execute(unsigned short,unsigned short*,unsi
addp4 ret2=0x21a,r32 MMI
---Type <return> to continue, or q <return> to quit---
0x20000000745f4520:1 <BaseStatement::execute(unsigned short,unsigned short*,unsi
0x20000000745f4520:2 <BaseStatement::execute(unsigned short,unsigned short*,unsi
End of assembler dump.
(gdb) info frame
Stack level 0, frame at 0x200000007ffecb00:
ip = 0x20000000745f44f0:1
in BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)
(base/source/baseexec.cpp:1102); saved ip 0x20000000745f00e0:0
called by frame at 0x200000007ffecb90
source language c++.
Size of frame is 51, Size of locals is 46, Size of rotating is 0.
NAT collections saved at 0x20000000777ff3f8.
Arglist at 0x20000000777ff390, args:
Locals at 0x20000000777ff390, Previous frame's sp is 0x200000007ffecb00

 

 

Please let me know if you can find any solution for this error.

 

Bhanu

4 REPLIES 4
Dennis Handly
Acclaimed Contributor

Re: Invalid address alignment - Program received signal SIGBUS, Bus error

>This code works on all platforms except this

 

This says you have an alignment trap.  Your 4 byte store address isn't 4 byte aligned:

0x20000000745f44f0:1 <BaseStatement::execute+0x1e31>:  st4

bhanu926
Occasional Visitor

Re: Invalid address alignment - Program received signal SIGBUS, Bus error

Hi Dennis Handly,

Thanks for the quick reply.

Can you explain me what the below statement means as I am not good at assembly language.

0x20000000745f44f0:1 <BaseStatement::execute(unsigned short,unsigned short*,unsigned short*)+0x1e31>: st4

Also when I said that this code works on other platforms I meant that it works on other unix flavours like Linux, Solaris.

Do you think changing the argument types to "long" in BaseStatement::execute(unsigned short,unsigned short*,unsigned short*) will fix this issue?

Thanks in advance.
Dennis Handly
Acclaimed Contributor

Re: Invalid address alignment - Program received signal SIGBUS, Bus error

>Can you explain me what the below statement means

 

First of all, the line is truncated and all that is there is the st4 and not the register operands.  If you have that and a dump of the registers (info reg), then you can confirm the bad alignment.

 

>when I said that this code works on other platforms

 

That's why it doesn't work here.  You are depending on the kindness of (strangers :-) x86 or of the OS.  HP-UX by default doesn't allow misaligned data.

 

>Do you think changing the argument types to "long"

 

No, that might make it worse.

Do you have debug info?  If so, using gdb, you can print out the values of your pointers to check alignment.

 (It does look like your code has been optimized.)

 

If you really need to operate on misaligned data, if you look at the link that gdb was mentioning, it mentions a bunch of pragmas and options you can try:

http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/HTML_Online_Help/pragmas.htm#data-align

bhanu926
Occasional Visitor

Re: Invalid address alignment - Program received signal SIGBUS, Bus error

Thanks Dennis Handly, I will try out your suggestions.