- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- BUS_ADRALN - Invalid address alignment, while C pr...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2012 12:54 AM
06-03-2012 12:54 AM
Hello,
Please help to resolve problem for C program on HP-UX B.11.31 U ia64, which is resulting in core dump while execution with
BUS_ADRALN 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 data: http://docs.hp.com/en/7730/newhelp0610/pragmas.htm#pragma-pack-ex3.
0x4000000000145280:1 in db_ins_curr_trans (umsg=0x87ffffffffff5920)
at ./dbcurrtran.pc:2528
2528 RAW_TO_ORACLE_VARCHAR_W_SZ( addldata,
(gdb) bt
#0 0x4000000000145280:1 in db_ins_curr_trans (umsg=0x87ffffffffff5920)
at ./dbcurrtran.pc:2528
#1 0x40000000000c1250:0 in speedup_db () at speedup_db.c:86
#2 0x40000000000a8970:0 in main (argc=1, argv=0x87fffffffffff338)
at tserv.c:184
(gdb)
_Unwind_InfoBlock::decodeVUF: Unrecognized flags 200000000000
Here is code list (partly):
int speedup_db( void )
{
umf_ent ct_rec;
memset( &ct_rec, 0, sizeof(umf_ent) );
db_ins_curr_trans( &ct_rec );
...
}
int db_ins_curr_trans( umf_ent *umsg )
{
RAW_TO_ORACLE_VARCHAR_W_SZ( addldata, umsg->iso.addldata + sizeof(size_t), *(size_t*)(umsg->iso.addldata) );
...
}
where RAW_TO_ORACLE_VARCHAR_W_SZ is macro:
#define RAW_TO_ORACLE_VARCHAR_W_SZ( dest, src, size ) \
raw_to_oracle_varchar( dest.arr, &dest.len, sizeof(dest.arr), src, size )
unsigned char *raw_to_oracle_varchar( unsigned char *dest, unsigned short *destlen, size_t destsize, const unsigned char *src, int srclen )
{
if( sizeof(char)*(2 * srclen) > destsize )
{
srclen = (destsize / sizeof(char)) / 2;
}
memset( (void *)dest, '\0', destsize );
*destlen = srclen * 2;
bchtoa( src, (char *)dest, srclen );
return dest;
} /* end of raw_to_oracle_varchar */
and umf_ent is a structure:
typedef struct
{
...
isost iso;
} umf_ent;
typedef struct
{
...
unsigned char addldata[ 1024 ];
...
} isost;
Solved! Go to Solution.
- Tags:
- SIGBUS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2012 03:10 AM - edited 06-03-2012 03:12 AM
06-03-2012 03:10 AM - edited 06-03-2012 03:12 AM
Re: BUS_ADRALN - Invalid address alignment, while C program execution on HP-UX B.11.31 U ia64
>RAW_TO_ORACLE_VARCHAR_W_SZ(addldata, umsg->iso.addldata + sizeof(size_t), *(size_t*)(umsg->iso.addldata));
It could be aborting trying load up a 8 byte aligned size_t at addldata. It appears that ct_rec is at least 8 byte aligned.
>typedef struct {
...
isost iso;
} umf_ent;
typedef struct {
...
unsigned char addldata[1024];
} isost;
These "..." are important. Do they have any pointers there that would align addldata on an 8 byte boundary?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2012 05:35 AM
06-03-2012 05:35 AM
Re: BUS_ADRALN - Invalid address alignment, while C program execution on HP-UX B.11.31 U ia64
Please find the header file attached, sorry for extradata in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2012 06:02 AM - edited 06-03-2012 06:04 AM
06-03-2012 06:02 AM - edited 06-03-2012 06:04 AM
Re: BUS_ADRALN - Invalid address alignment, while C program execution on HP-UX B.11.31 U ia64
>Please find the header file attached, sorry for extra data in advance.
You are going to have to do your homework and let the compiler compute this offset info for us.
Add this to your program and supply the results:
#include <stddef.h>
#include <stdio.h>
printf("offset of addldata: %lu\n", offsetof(isost, addldata));
printf("offset of iso:%lu\n", offsetof(umf_ent, iso));
This is likely only a multiple of 4 and not 8 for 64 bit mode.
Or just go into the debugger and in db_ins_curr_trans, print out:
p umsg->iso.addldata
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2012 07:36 AM
06-03-2012 07:36 AM
Re: BUS_ADRALN - Invalid address alignment, while C program execution on HP-UX B.11.31 U ia64
current results:
offset of addldata: 1332
offset of iso: 816
(gdb) p umsg->iso.addldata
$1 = '\000' <repeats 1023 times>
so, now I've noticed that recently one field was added to umf structure and length of the other one was changed, so before these changes the result of offset of addldata was multiple of 8 and there was no BUS_ADRALN error raised:
offset of addldata: 1312
offset of iso: 816
But even before changes it seems to be dangerous way to expect / fit this offset to be always multiple of 8 - sizeof(size_t). Am I right ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2012 08:41 AM
06-03-2012 08:41 AM
Re: BUS_ADRALN - Invalid address alignment, while C program execution on HP-UX B.11.31 U ia64
Dennis, thank you very much. I think now I undestand the problem with data alignment in the program and now have ideas how this should be resolved.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2012 02:06 PM
06-03-2012 02:06 PM
Solution>offset of addldata: 1332 offset of iso: 816
The sum of the two in hex is: 0x864 (so 4 byte aligned)
>(gdb) p umsg->iso.addldata $1 = '\000' <repeats 1023 times>
I guess you needed to take the address: p &umsg->iso.addldata[0]
>it seems to be dangerous way to expect / fit this offset to be always multiple of 8 - sizeof(size_t).
Easily solved. Add an alignment bitfield:
int ppmci;
size_t :0; // align next field
unsigned char addldata[UMF_ADDLDATA_SZ];
>thank you very much.
If you are happy with the answers, please click on the Kudos stars.
offset of iso: 816
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2012 02:58 AM
06-04-2012 02:58 AM
Re: BUS_ADRALN - Invalid address alignment, while C program execution on HP-UX B.11.31 U ia64
> I guess you needed to take the address: p &umsg->iso.addldata[0]
Да, извиняюсь:
(gdb) p &umsg.iso.addldata
$1 = (unsigned char (*)[1024]) 0x87ffffffffffdf74
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2012 06:26 PM
06-04-2012 06:26 PM
Re: BUS_ADRALN - Invalid address alignment, while C program execution on HP-UX B.11.31 U ia64
>$1 = (unsigned char (*)[1024]) 0x87ffffffffffdf74
This shows the alignment is just 4.