What's the difference between Segmentation fault and Bus error and Illegal...?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers What's the difference between Segmentation fault and Bus error and Illegal...?
# 1  
Old 03-28-2008
Question What's the difference between Segmentation fault and Bus error and Illegal...?

What's the difference between Segmentation fault and Bus error and Illegal instruction?

Sometimes I got the one, and sometimes i got another, what are their differences?

Segmentation fault (core dump)?

Bus error (core dump)?

Illegal instruction (core dump)


Thanks


Daniel
# 2  
Old 03-28-2008
Segmentation Fault (also known as SIGSEGV and is usually signal 11) - You can get this message when the program tries to write/read outside the memory allocated for it or when writing memory which can only be read

Bus Error (also known as SIGBUS and is usually signal 10) - You can encounter this signal error when an invalid pointer is dereferenced i.e when you try to dereference an uninitialised pointer. It is similar to SIGSEGV but the difference is that SIGSEGV indicates an invalid access to valid memory, while SIGBUS indicates an access to an invalid address.

Illegal Instructions (also known as SIGILL and is usually signal 4) - This usually means that your program is trying to execute garbage or a privileged instruction. You might encounter this -
(a.) when you try to execute data
(b.) when you try to execute a corrupted executed file.
(c.) stack overflows
(d.) when the system has trouble running the handler for a signal

HTH
# 3  
Old 03-28-2008
Quote:
Originally Posted by ajitabhpandey
Segmentation Fault (also known as SIGSEGV and is usually signal 11) - You can get this message when the program tries to write/read outside the memory allocated for it or when writing memory which can only be read

Bus Error (also known as SIGBUS and is usually signal 10) - You can encounter this signal error when an invalid pointer is dereferenced i.e when you try to dereference an uninitialised pointer. It is similar to SIGSEGV but the difference is that SIGSEGV indicates an invalid access to valid memory, while SIGBUS indicates an access to an invalid address.

Illegal Instructions (also known as SIGILL and is usually signal 4) - This usually means that your program is trying to execute garbage or a privileged instruction. You might encounter this -
(a.) when you try to execute data
(b.) when you try to execute a corrupted executed file.
(c.) stack overflows
(d.) when the system has trouble running the handler for a signal

HTH
Thank you, HTHSmilie

I wonder is there any good book on unix or linux debugging?
Could anybody recommend one?

Daniel
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

C. To segmentation fault or not to segmentation fault, that is the question.

Oddities with gcc, 2.95.3 for the AMIGA and 4.2.1 for MY current OSX 10.14.1... I am creating a basic calculator for the AMIGA ADE *NIX emulator in C as it does not have one. Below are two very condensed snippets of which I have added the results inside the each code section. IMPORTANT!... (11 Replies)
Discussion started by: wisecracker
11 Replies

2. Programming

Segmentation Fault ERROR in C

Hello guys, i have this code: int main(int argc, char *argv) { int i, j, N, result = 0, **vec; if (argc < 2) { fprintf(stderr, "Usage: %s N\n", argv); } /* ... how many numbers to read */ N = atoi(argv); /* check if N is a power of two; exit if not */ if (!... (3 Replies)
Discussion started by: DinisR
3 Replies

3. Programming

Using gdb, ignore beginning segmentation fault until reproduce environment segmentation fault

I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this : i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
Discussion started by: pooyair
6 Replies

4. UNIX for Dummies Questions & Answers

Segmentation fault

#include<stdio.h> #include<malloc.h> #include<unistd.h> #include<stdlib.h> void *start_1(void *argv) { printf("thread 0x%x\n",(unsigned int)pthread_self()); pthread_exit((void*)1); } void *start_2(void *argv) { printf("thread 0x%x\n",(unsigned int)pthread_self()); return (void*)2; }... (2 Replies)
Discussion started by: vincent__tse
2 Replies

5. UNIX for Advanced & Expert Users

segmentation fault with ps

What does this mean and why is this happening? $ ps -ef | grep ocular Segmentation fault (core dumped) $ ps -ef | grep ocular Segmentation fault (core dumped) $ ps aux | grep ocular Segmentation fault (core dumped) $ ps Segmentation fault (core dumped) $ pkill okular $ ps... (1 Reply)
Discussion started by: cokedude
1 Replies

6. Programming

Segmentation fault in C

i have this code int already_there(char *client_names, char *username) { int i; for(i = 0; i<NUM; i++) { printf("HERE\n"); if (strcmp(client_names, username)==0) return(1); } return(0); } and i get a segmentation fault, whats wrong here? (7 Replies)
Discussion started by: omega666
7 Replies

7. Programming

getting Segmentation Fault (core dumped) error but Program runs fine.

i am executing following program int main() { char str; FILE * fp; int i=0; ... (4 Replies)
Discussion started by: bhavesh.sapra
4 Replies

8. Shell Programming and Scripting

Segmentation Fault(Core Dump) Error

Hi all, I have a folder with some 28 files. I have a script file that will iteratively take one file at a time from the folder and provide an output for the input file. Till the 7th file, there was no problem but from the 8th file onwards, i got this Segmentation Fault(Core Dump) error. A file... (2 Replies)
Discussion started by: mick_000
2 Replies

9. UNIX for Advanced & Expert Users

capture sqsh segmentation fault error

hi all is there any way to capture the segmentation fault error when i run sqsh on a unix shell script. Ex: #!/bin/ksh sqsh -S "server" -U "user" -P "pwd" << EOF use mydb go exec proc1 go exit EOF retval=$? echo "sqsh return value $retval" if then exit (1 Reply)
Discussion started by: sudheer1984
1 Replies

10. UNIX for Dummies Questions & Answers

Segmentation Fault

Hi, While comparing primary key data of two tables thr bteq script I am getting this Error. This script is a shell script. *** Error: The following error was encountered on the output file. Script.sh: 3043492 Segmentation fault(coredump) Please let me know how to get through it. ... (5 Replies)
Discussion started by: monika
5 Replies
Login or Register to Ask a Question