It is currently Sat, 04 Feb 2023 11:12:45 GMT

Author Message
 Unaligned access (bus error) on Solaris on global variable
OS: Solaris 8
Machine: Sun Blade 100

We had an application which runs under Solaris8/Sparc.

We ported it to Solaris8/x86 to modify it.

We brought it back under Solaris8/Sparc and this resulted in a bus
error at runtime.

The problem is an access to a global variable (an unsigned short):
moving the declaration of that variable before other prevoius
variables makes it run.


=========== This causes the problem
... /* Misc declarations */
char a, b, c, d, e, f, g;
unsigned short w1, w2, w3, w4, w5;

void f()
  if (w2>0) { /* This results in bus error */

=========== This solves the problem
... /* Misc declarations */
unsigned short w1, w2, w3, w4, w5;
char a, b, c, d, e, f, g;

void f()
  if (w2>0) { /* This now runs */


I don't think it's normal. The alignment of global data should be
automatic, isn't it?
Moreover it runs good in the first application version.

Any idea? Tnx.

 Sun, 06 Nov 2005 00:24:10 GMT   
 Unaligned access (bus error) on Solaris on global variable
[alignment problem]

Indeed. Which compiler, which assembler, and which linkage editor was
used? Do you have the assembler text generated by that compiler (option
-S)? If yes, put it on some web page and post the URL. Do the same with
the output of `nm' for the object file.


Dr. Andreas F. Borchert, SAI, Universitaet Ulm | One should make everything
Helmholtzstrasse 18, E02, Tel +49 731 50-23572 | as simple as possible, but | no simpler. -- A. Einstein

 Sun, 06 Nov 2005 00:30:05 GMT   
 Unaligned access (bus error) on Solaris on global variable

Which compiler are you using? Forte 6 Update 2 doesn't like
the function f() and the char f sharing the same name AT ALL!

Noel R. Nihill
UNIX? platform development
Motorola NSS
I *could* be arguing in my spare time.

 Sun, 06 Nov 2005 00:50:01 GMT   
   [ 3 post ] 

Similar Threads


2. accessing a global variable

3. How to set environment variable for global access?

4. Parent and Child process accessing global variable?

5. fork + accessing global variable

6. Accessing global variables from shared/dynmaic functions.

7. Unaligned access error

8. Fixing unaligned access Solaris 2.3

9. Global variables inside shared library on Solaris

10. file contents into variable, or global variable from shell script

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software