[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::axp-developer

Title:Alpha Developer Support
Notice:[email protected], 800-332-4786
Moderator:HYDRA::SYSTEM
Created:Mon Jun 06 1994
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3722
Total number of notes:11359

3481.0. "landmark" by HYDRA::DORHAMER () Mon Apr 14 1997 16:08

    Company Name :  landmark
    Contact Name :  shyam h
    Phone        :  
    Fax          :  
    Email        :  [email protected]
    Date/Time in :  14-APR-1997 15:07:24
    Entered by   :  Karen Dorhamer
    SPE center   :  MRO

    Category     :  UNIX
    OS Version   :  3.2
    System H/W   :  


    Brief Description of Problem:
    -----------------------------
    #2          14-APR-1997 13:33:30.20                                 
NEWMAIL
From:   SMTP%"[email protected]"
To:     alpha-developer <[email protected]>
CC:     "[email protected]" <[email protected]>
Subj:   Unalligned access Error Message

Hello,
We are porting our product, which was running on all 32-bit OS's, to
Digital UNIX 3.2.  There is a 'storetxt' program, which logs ('stores')
data from an external platform.  Data from external platform is received
thru a TCP-IP socket.

Whenever, data from a 32-bit platform (Solaris-2.x, or HP-UX9.x) is
written to this 'store' running on a digital UNIX platform, I am getting
the following error message:
"Unaligned access pid=26697 <storetxt> va=14016553d pc=120109230
ra=1201028bc type=lds"

To give a brief background of the porting efforts:
There were many variables declared as 'long'.  While porting the product
onto DEC, all these declarations were modified to 'int' so that data
from 32-bit machines are compatible with (occupy the same space as)'int'
data on Digital.  However, we have not modified pointer variables.

After all these changes, the 'store' works fine on Digital and even logs
the data, in spite of the above error message.

Is this error because of the boundary allignment in such structures,
which have a 'char *' field immediately followed by an 'int' field.
 Do I have to modify such structures, which have a mixture of char,
pointer and int variables?

We are using gcc-2.7.2.1 compiler - sources are mostly C++ files.  Very
few are C files.

An early reply will be greatly appreciated.

Thanks,

Shyam
T.RTitleUserPersonal
Name
DateLines
3481.1FAQ info on unaligned accessesHYDRA::DORHAMERMon Apr 14 1997 16:12155
        #2          14-APR-1997 15:06:07.47                                 
    NEWMAIL
    From:   HYDRA::AXPDEVELOPER "[email protected]"
    To:     SMTP%"[email protected]"
    CC:     AXPDEVELOPER
    Subj:   RE: Unalligned access Error Message
    
    Shyam,
    
    The unaligned access messages that you are receiving will not cause the
    software to fail, but can cause significant performance degradation for your
    application.  My recommendation is that you modify your application to avoid
    generating unaligned accesses.  Attached is some info on what causes 
    unaligned accesses and how to track down the source of the unaligned 
    accesses in your application.  This is from one of our FAQ web pages found 
    at:
    
    http://www.partner.digital.com/www-swdev/pages/Home/TECH/faqs/dunix/unalign.html
    
    Karen Dorhamer
    Alpha Developer Support
    
    FAQs About Unaligned Access on Digital UNIX
    
    
      1.How are data accessed on Alpha?
    
    The Alpha architecture supports longword (32-bits) and quadword (64 bits) memory
    accesses. Byte and word accesses (on EV4 and EV5 Alpha Architectures) are
    achieved through the use of multiple instructions (load as a longword
    or quadword;
    mask and shift to retrieve the byte or word).
    
      2.How are data aligned on Alpha?
    
    Longwords (e.g. an int) are aligned on 4-byte boundaries.
    
    Quadwords (e.g. a long) are aligned on 8-byte boundaries.
    
    Float data types are aligned on 4-byte boundaries.
    
    Long, double, and pointers are aligned on 8-byte boundaries.
    
    A structure as a whole is aligned on the boundary of the largest
    element contained therein.
    
    .Am I getting unaligned access warnings?
    
    On Digital UNIX systems, you can enable or disable reporting of the
    "unaligned access" warnings by using:
    
                 uac p         -  shows current process uac setup
                 uac p 1       -  Enables unaligned access message control for the
                                  current process
                 uac p 0       -  Disables unaligned access message control
    for the
                                  current process
                 uac s         -  shows system uac setup
    
                                         
    NOTE: Default settings for uac under Digital UNIX V4.0 running CDE is:
    
                       % uac p
                       parent printing is off
                       fixup is on
                       sigbus is off
    
    4.What causes unaligned access errors?
    
    Unaligned accesses may occur for a number of reasons. For instance,
    while the
    compiler does its best to naturally align data and variables, it may
    not know en
    ough
    about the entire application to make all the correct assumptions. Some
    reasons f
    or
    unaligned access are:
            Parameters being passed into functions
            Pointers (64 bits) cast as ints (32 bits)
    Multithreaded applications on multiple processors, not using proper
    lockings
    techniques, may experience synchronization problems while accessing
    common data
    through a common address space. This is especially a problem when char,
    byte, an
    d
    word data are used.
    Structures and unions (size, member alignment, structure alignment,
    etc. are han
    dled
    differently by the Alpha architecture than by 32-bit architectures.
    Library calls, such as printf(), scanf(), malloc(), calloc(), lseek(),
    fsetpos()
     and
    fgetpos() are handled differently by the Alpha architecture. i.e. size
    of parame
    ters to
    these functions may differ from 32-bit systems.
    Constants may have different values between 32-bit and 64-bit systems.
    This
    becomes an issue when exchanging data between these systems.
    Accessing data in old files, or files shared between 32-bit and 64-bit
    systems.
    
    5.How do I get rid of "unaligned access" errors?
    
    So you see this kind of error message?!
    
    Unaligned access pid=2276 <unalign> va=11ffffd01 pc=120001188
    ra=120001100 type=
    stq
    
    
    The message above says: program unalign has an unaligned access at PC
    Address
    0x120001188.
    
    To isolate where the error message comes from:
    
    Write down the PC Address reported by the message. i.e. pc=120001188
    
    Run the debugger, specifying the executable file with the unaligned
    access. i.e.
    
    
                      % dbx unalign
    
    
    Set break at the pc address and run. i.e.
    
                      dbx> stopi at 0x120001188
                      dbx> run
    
    
    Once stopped at the break point, use the "where" command and find the
    source
    line for the fault.
    
    Knowing where the problem lies, try to fix it.
    
    Fixing the code requires an understanding of the code and how it
    interfaces
    with other parts of the code. The resolution may require code changes
    as well
    as specifying additional compiler options such as -xtaso or
    -nomember_alignment .
    
    Recompile, relink and try again.
    
    A good example for the process of finding and fixing unaligned access
    problems is given in THIS PAGE.
    
    Note: Additional information on this topic can be obtained from the DEC
             OSF/1 AXP debugger manual or man pages on your compiler.
3481.2found the problemHYDRA::DORHAMERWed Apr 16 1997 10:4612
    From:   SMTP%"[email protected]" 15-APR-1997 16:48:01.25
    To:     [email protected] ([email protected])
    CC:
    Subj:   Re: Unalligned access Error Message
    
    Karen,
    Great!  I ran the program under dbx, gave the break point at the PC value
    where there was an 'unaligned acces'.  This procedure helped me in
    determining the fragment of source code, which had the bug, and was
    able to solve the problem in a minute.  Thanks very much!
    
    Shyam