The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk Shell Script error : "Syntax Error : `Split' unexpected Herry UNIX for Dummies Questions & Answers 2 03-17-2008 08:16 AM
error during run: St9bad_alloc - Getting this error while using some conversion progr sathu_pec Shell Programming and Scripting 1 01-20-2008 11:38 PM
I got error like...syntax error on line 1, teletype koti_rama UNIX for Advanced & Expert Users 2 07-07-2007 04:35 PM
error reading sections error at install doelman SUN Solaris 2 02-05-2007 09:21 AM
Error: Internal system error: Unable to initialize standard output file firkus UNIX for Dummies Questions & Answers 2 10-25-2005 12:23 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-09-2001
LivinFree's Avatar
Goober Extraordinaire
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
Bus Error

This may belong in the C Programming forum, but here goes anyway...

What would cause a bus error? I searched google for a cause, but came up with some conflicting reports...
Could it be caused by [lack of] disk space?
A lot of the pages I found mentioned linking with the incorrect versions of the library. But in that case, would it compile correctly?

Basically, I am curious as to why we had a job dump core on a bus error. It ran nearly to normal completion time, then simply poo-pood.

In the case that it may make a difference, it's a job that interfaces with an Oracle database on HP-UX 11. The things that had changed were that the process was recompiled, AND we were at 96% (df -k) on that disk...

Not too important for me to know right now, but I am curious, and who wants to wait for developers to tell me what happened?
Forum Sponsor
  #2  
Old 11-09-2001
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
The bus in question is the address buss and it contains an illegal value. This is almost always the result of dereferencing a pointer that contains an illegal value.

Here is a program that, I think, will compile with every C or C++ compiler, but should cause a bus error when the second printf is attempted...

Code:
#ifdef __STDC__
#define PROTOTYPICAL
#endif
#ifdef __cplusplus
#define PROTOTYPICAL
#endif

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#ifdef PROTOTYPICAL
int main(int argc, char *argv[])
#else
main(argc,argv)
char *argv[];
#endif
{
      double d = 1.23456789;
      double *p = &d;
      printf ( " d = %f \n" , *p);
      p = (double *)((char *)p + 1);
      printf ( " d = %f \n" , *p);
      exit(0);
}

Last edited by Perderabo; 01-16-2005 at 12:30 PM. Reason: Remove html which is no longer supported
  #3  
Old 11-09-2001
Registered User
 

Join Date: Nov 2001
Location: China
Posts: 18
I only know that if one trys to access a memory which in a readonly segment, the system will bumpup a Bus Error signal.
  #4  
Old 11-09-2001
TioTony's Avatar
Bit Pusher
 

Join Date: Oct 2001
Location: Southern California
Posts: 332
Do you have the source for the program? You could always examine the core to find out what is happening.
  #5  
Old 11-10-2001
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
Quote:
Originally posted by tonyt
I only know that if one trys to access a memory which in a readonly segment, the system will bumpup a Bus Error signal.
By "access" I guess you mean trying to store something there. Not to belabor the obvious, but it is legal to read a read-only segment.

There are two signals that can be delivered to a process that attempts something with an illegal memory address:

SIGBUS (ksh will say Bus error(coredump))
SIGSEGV (ksh will say Memory fault(coredump))

I've been looking through my library and I can't find any documentation that states which signal must be delivered under a specific condition. It may be that some versions of unix only use one or the other for everything. The kernel really depends on the cpu to catch these and it may be that some cpu's simply have a single trap to handle all bad addresses.

Still to me these errors have slightly different meanings, although I must admit that this is based mostly on C programming in an HP-UX environment.

SIGBUS means that you have asked to cpu to do something that is impossible. More to the point, the cpu can catch this error immediately by looking at the virtual address. There is no need to even attempt to convert the virtual address to a physical address. This is why cpu's bother to have a two-tiered check on an address. Converting a virtual address to a physical address can be a somewhat expensive operation.

SIGSEGV means that you have asked the cpu to do something that is illegal. If the kernel wanted to, it could fiddle with things to render the attempted operation legal. This error is caught after the attempted conversion of the virtual address to a physical address.

I would tend to expect that the situation tonyt is describing would result in a SIGSEGV rather than a SIGBUS....except that if you have a pointer that is both misaligned and in the wrong segment, you won't get both signals, you only get a SIGBUS. If an int is 4 bytes on your system and you try to store an int at random addresses in a read-only segment, then yes 75% of the time you will get a SIGBUS, while 25% of the time your pointer is aligned and you get the SIGSEGV.

Still tonyt may have a system that works differently than mine. And if a system can only deliver a single signal for address problems, SIGBUS would be my choice.
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 04:01 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0