![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
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
|
||||
|
||||
|
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
|
|||
|
|||
|
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
|
||||
|
||||
|
Do you have the source for the program? You could always examine the core to find out what is happening.
|
|
#5
|
||||
|
||||
|
Quote:
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 |