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