Unaligned access (bus error) on Solaris on global variable

Unaligned access (bus error) on Solaris on global variable

Post by Maurizio Fuschet » Thu, 22 May 2003 01:24:10



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.

Example:

=========== 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 */
     ...
  }

Quote:}

=========== 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 */
     ...
  }

Quote:}

===================================

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.

 
 
 

Unaligned access (bus error) on Solaris on global variable

Post by Andreas Borche » Thu, 22 May 2003 01:30:05


[alignment problem]

Quote:> I don't think it's normal. The alignment of global data should be
> automatic, isn't it?

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.

Andreas.

--
Dr. Andreas F. Borchert, SAI, Universitaet Ulm | One should make everything
Helmholtzstrasse 18, E02, Tel +49 731 50-23572 | as simple as possible, but
http://www.mathematik.uni-ulm.de/sai/borchert/ | no simpler. -- A. Einstein

 
 
 

Unaligned access (bus error) on Solaris on global variable

Post by Noel R. Nihil » Thu, 22 May 2003 01:50:01



Quote:> 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.

> Example:

> =========== 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.

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.

 
 
 

1. XIRCOM CARD BUS 56 GLOBAL ACCESS

1. Is XIRCOM CARD BUS 56 GLOBAL ACCESS (10/100 + 56k) working under OpenBSD
3.0 ?
2. Is it possible use it during install process ? I plan to buy it for my
old laptop and will need to install system using LAN connection since I
don't have CD-ROM drive in this old machine.
3. Any other recommendation for a card with integrated RJ-45 socket?

Thanks

2. Limiting number of Connections to Apache 1.2b?

3. accessing a global variable

4. Win98 + Linux (samba)

5. fork + accessing global variable

6. OpenBSD install on sun4m (sparc 5)

7. Parent and Child process accessing global variable?

8. Does Linux do Internet routing?

9. Accessing global variables from shared/dynmaic functions.

10. How to set environment variable for global access?

11. Unaligned access error

12. Fixing unaligned access Solaris 2.3

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