- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Compiler Issue on PA-RISC when Accessing Unaligned...
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
Forums
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
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
05-02-2007 03:39 AM
05-02-2007 03:39 AM
Background: we are attempting to minimize memory usage in areas where 10s of millions of items may exist. Using #pragma pack(1) to pack structures as much as possible and then these structures are being packed (along with other data) into large blocks of malloc'ed memory. Due to the variable nature of the other data, the structures may be aligned on any byte boundary, which should be ok as the pragma implies alignment of 1 as well.
On PA-RISC machines, we have been seeing "Bus error (core dumped)" messages and have narrowed it down to alignment when doubly de-referencing pointers to that memory. i.e. if we align the structures it works, or if we copy the pointer and then de-reference it works too!
Output of "uname -a" is: HP-UX dh-holly B.11.11 U 9000/800 3314646695 unlimited-user license
Compiler version is: HP ANSI C++ B3910B A.03.65
The same source code works OK on HP Itanium machine with
Output of "uname -a" is: HP-UX dh-ida B.11.23 U ia64 2988385317 unlimited-user license
Compiler version is: HP aC++/ANSI C B3910B A.06.05 [Jul 25 2005]
Build and Run Instruction: Build it with aCC and run it.
/********** Source code *************/
#include
#include
typedef struct
{
int i;
} REF_LEVEL_T;
#pragma pack 1
typedef struct
{
REF_LEVEL_T *pRefLevel;
char c; // doesn't core if this is moved above pRefLevel
} REF_MEMBER_T;
#pragma pack 0
typedef struct
{
REF_MEMBER_T *pRefMember;
} MEMBER_T;
int main()
{
REF_LEVEL_T RefLevel;
MEMBER_T Member;
RefLevel.i = 0;
char *p = (char *)malloc( 1000 );
for (int unalignBytes = 0; unalignBytes < 4; unalignBytes++)
{
fprintf( stderr, "trying unalignBytes %d\n", unalignBytes );
REF_MEMBER_T *pRefMember = (REF_MEMBER_T *)(p+unalignBytes);
pRefMember->pRefLevel = &RefLevel;
Member.pRefMember = pRefMember;
REF_MEMBER_T *pTestRefMember = Member.pRefMember;
int x = pTestRefMember->pRefLevel->i;
fprintf( stderr, "passed first test\n" );
int y = (Member.pRefMember)->pRefLevel->i;
fprintf( stderr, "passed second test\n" );
}
}
Solved! Go to Solution.
- Tags:
- unaligned
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2007 06:00 AM
05-02-2007 06:00 AM
Re: Compiler Issue on PA-RISC when Accessing Unaligned Packed Structures
You've followed the guidelines for making code work on Itanium and PA-RISC.
Oracle couldn't do it, they maintain different code bases for Itanium versus PA-RISC
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2007 07:32 AM
05-02-2007 07:32 AM
Re: Compiler Issue on PA-RISC when Accessing Unaligned Packed Structures
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2007 07:50 AM
05-02-2007 07:50 AM
Re: Compiler Issue on PA-RISC when Accessing Unaligned Packed Structures
# aCC +u1 your_prog.c
# ./a.out
trying unalignBytes 0
passed first test
passed second test
trying unalignBytes 1
passed first test
passed second test
trying unalignBytes 2
passed first test
passed second test
trying unalignBytes 3
passed first test
passed second test
~cheers
- Tags:
- +u1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2007 12:37 PM
05-02-2007 12:37 PM
Re: Compiler Issue on PA-RISC when Accessing Unaligned Packed Structures
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2007 02:52 AM
05-03-2007 02:52 AM
Re: Compiler Issue on PA-RISC when Accessing Unaligned Packed Structures
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2007 03:11 AM
05-03-2007 03:11 AM
Solution- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2007 03:13 AM
05-03-2007 03:13 AM
Re: Compiler Issue on PA-RISC when Accessing Unaligned Packed Structures
Thank you all very much for the help.
Dekun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2007 03:15 AM
05-03-2007 03:15 AM
Re: Compiler Issue on PA-RISC when Accessing Unaligned Packed Structures
Thanks for the help