Bus error in solaris

Bus error in solaris

Post by Boris Goldber » Thu, 03 Sep 1998 04:00:00



< Hi,  I am working on solaris 2.6 (sparc) and i m having a lot of
problems of
< bus error ..core dumped. I checked my code and one common thing that i
found
< was that most of the errors ocurr at a point where the pointers are
type
< casted. When i use dbx to debug the application i m able to access the
memory
< and i can see the contents of that memory but without de* the
< application gives bus error...core dumped. I tried to get help from a
lot of
< manuals but i couldn't find anything interesting.  can anybody please
help

Time to re-read a C manual, ah?

Pointer type-casting is dangereous and may cause alignment problems
resulting in SIGBUS.

main()
{

 char buf[] = "disaster";

 int *p = (int *)&buf[0];

 cout << *p << endl;   // coredumps on Sun, but necessarily on
                       // other architectures, like MIPS or Intel

Quote:}

 
 
 

Bus error in solaris

Post by Mark R. Dzmur » Thu, 03 Sep 1998 04:00:00


The most common cause of bus errors on a SPARC is mis-aligned memory
references.

For example, if you try to access a 16-bit value on an odd address,
you will get a bus error.

Your observation about casting is correct - inappropriate casting of
pointers is a common cause of bus errors.

Your problem might be simply fixed, or it might be caused by the
nature of the software design.  I hope for your sake that the
problems are simple.

Good luck,
mdz

--
   _____________________________________________________________
  /                             |                               \

/  Senior Software Engineer     | telephone: 412-787-8222 x210    \
\  Aspen Technology, Inc.       | FAX: 412-787-8220               /
 \  NeuralWare Business Unit    | www: http://www.aspentec.com   /
  \_____________________________|_______________________________/

 
 
 

Bus error in solaris

Post by Mattias H?gstr? » Thu, 03 Sep 1998 04:00:00



> Time to re-read a C manual, ah?

> Pointer type-casting is dangereous and may cause alignment problems
> resulting in SIGBUS.

> main()
> {

>  char buf[] = "disaster";

>  int *p = (int *)&buf[0];

>  cout << *p << endl;   // coredumps on Sun, but necessarily on
>                        // other architectures, like MIPS or Intel
> }

Is the only way of avoiding bus error to copy the data into 'int' aligned
memory?

char tmp=buf[0];
int p=tmp;
cout << p << endl;

or could it be done in a better way with some magic?

/Mattias H?gstr?m

 
 
 

Bus error in solaris

Post by powersta » Thu, 03 Sep 1998 04:00:00


befor you go further, why dont you go to the ok prompt, you did not say
which cpu you had, do a help test, and run some hardware diagnostics, to
make sure nothing is wrong with your memory(hardwarewise)
http://www.powerstarinc.com
 
 
 

Bus error in solaris

Post by Casper H.S. Dik - Network Security Engine » Fri, 04 Sep 1998 04:00:00


[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]


>Hi,  I am working on solaris 2.6 (sparc) and i m having a lot of problems of
>bus error ..core dumped. I checked my code and one common thing that i found
>was that most of the errors ocurr at a point where the pointers are type
>casted. When i use dbx to debug the application i m able to access the memory
>and i can see the contents of that memory but without de* the
>application gives bus error...core dumped. I tried to get help from a lot of
>manuals but i couldn't find anything interesting.  can anybody please help


Pointers need to be properly "naturally" aligned on SPARC

Natural alignment means that the basic types (char, short, int, float, double,
long) all need to be aligned at a proper multpile of their size.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

 
 
 

Bus error in solaris

Post by Mattias H?gstr? » Fri, 04 Sep 1998 04:00:00


Quote:> > main()
> > {

> >  char buf[] = "disaster";

> >  int *p = (int *)&buf[0];

> >  cout << *p << endl;   // coredumps on Sun, but necessarily on
> >                        // other architectures, like MIPS or Intel
> > }

> Is the only way of avoiding bus error to copy the data into 'int' aligned
> memory?

> char tmp=buf[0];
> int p=tmp;
> cout << p << endl;

int p;
p=buf[0];
is better of course.

Is it a rule to never to make a cast to a pointer type that is of larger size
if you want to extract the value?
Now I think I know why earlier versions of Netscape crashed  so often,
the platform independent code was not always considering memory alignment.

/M

 
 
 

Bus error in solaris

Post by Boris Goldber » Fri, 04 Sep 1998 04:00:00


< Is it a rule to never to make a cast to a pointer type that is of
larger size
< if you want to extract the value?

I think so.

< Now I think I know why earlier versions of Netscape crashed  so often,
< the platform independent code was not always considering memory
alignment.

My latest Netscape crashes every other day, and hangs every day...

 
 
 

Bus error in solaris

Post by Joerg Schilli » Fri, 04 Sep 1998 04:00:00




>< Is it a rule to never to make a cast to a pointer type that is of
>larger size
>< if you want to extract the value?
...
>< Now I think I know why earlier versions of Netscape crashed  so often,
>< the platform independent code was not always considering memory
>alignment.

>My latest Netscape crashes every other day, and hangs every day...

Double the amount of RAM in your machine and you will double the time
between crashes.

I am wondering if Netscape will ever close the memory leaks.

Joerg

--



URL:  http://www.fokus.gmd.de/usr/schilling    ftp://ftp.fokus.gmd.de/pub/unix

 
 
 

Bus error in solaris

Post by Daniel Barke » Tue, 08 Sep 1998 04:00:00



> Hi,  I am working on solaris 2.6 (sparc) and i m having a lot of problems of
> bus error ..core dumped. I checked my code and one common thing that i found
> was that most of the errors ocurr at a point where the pointers are type
> casted. When i use dbx to debug the application i m able to access the memory
> and i can see the contents of that memory but without de* the
> application gives bus error...core dumped. I tried to get help from a lot of
> manuals but i couldn't find anything interesting.  can anybody please help


The free compiler GNU C (gcc) can diagnose many problems at compile-time:
look into "-Wcast-align", "-Wall -O3", and related options. For static
checks, you might also find Solaris "lint" useful.

When running through dbx (for SPARC), before running the executable turn
on run-time memory checking with

  check -all
  unsuppress all

this will give you specific information on the error, e.g. misaligned
write, misaligned read, misaligned free. (And will also tell you about
many other problems, e.g. reading from uninitialized memory.)

With Sun C for SPARC, there are compiler options to relax assumptions
about alignment: look into "-misalign" "-misalign2". This is only suitable
as a temporary fix, for example if someone else wrote the code and is
taking a couple of weeks to sort out the bug.

Daniel Barker,
Institute of Cell and Molecular Biology,
Swann Building,
King's Buildings,
Mayfield Road,
Edinburgh
EH9 3JR
UK

 
 
 

1. Solaris 2.4, Oracle 7.2.2.3, inodes, bus errors, and I/O errors

Using Solaris 2.4 on a 20 with Oracle.  Oracle has been running on this
machine for over a year.  Typically it has been pretty reliable - Until the
new year.

Lately we are receiving messages that file systems are full when they are not.
We receive messages that the /opt filesystem is out of inodes when df -e
indicates that there are over 400,000 free.
And any executable we run from /opt returns a bus error.
If we change directories into /opt we randomly receive "No device or Bad
Address" messages when navigating into subdirectories.

When these messages begin, Oracle returns "EOF on communication channel"
errors when trying to connect remote through SQLNet V2.  Oracle/Solaris
returns "Bus error" messages when trying to connect from the server itself.

After a reboot the messages go away then return 2 to 8 hours later.  It seems
to be Oracle usage related but no pattern has been established.

Any thoughts ?
Is it Oracle ? Solaris ? Hardware ?

Thanks
  Wayne

2. PCI Modem Blaster 56k modem

3. Errors: Bus Error and Error 554

4. Problems with Colour on ATI mach64 Graphics Adapter

5. Bus Error during install of Solaris 10 s10_58 x86

6. Looking for gcc on Solaris 7/Intel

7. SIGBUS: Bus Error: E450/solaris 2.6

8. 2.5.63 wireless loading problem

9. f77 on Solaris, bus error -> compiler bug??

10. Apache 1.3.12 - Solaris 8, Ultra 1 Bus Error

11. f77 on Solaris, bus error -> compiler bug??

12. bus errors in multithreaded applications under Solaris 2.4

13. Solaris 2.5.1 - strange bus errors and core dumps...