Segmentation Fault Run Time Error | Trace Out Debugging Using gdb


That computer Physical Memory managed by the OS. It has different segmentation,
It will used for the storing data,variables,text,garbage values,
when we try to access memory location if it outside, or not able to read/write, or due to security it is not allow to access due to that segmentation fault occur.
Segmentation fault. It is Run Time Error.
1)if we are not assign the pointer in the correct format. like,
char *s = "hello world";
*s = 'H';
Pointer it is read only data type.
Reason- Already Pointer assign hello world, then we can't overwrite the value,.
Here it is attempting to write the read -only data due to that we are facing Segmentation Fault.
2)int i;
it will also generate Segmentation Fault Error.
Main Reason
1)rarely Compute Hardware is broken,
2)Bug in the program Source Code.
3)It can also appear when you try to access an array beyond the end of an array under C programming.
We can trace out these error using gdb command | Debugging Segmentation Fault
gdb- GNU Project Debugger
How to Run the Program under gdb
# gdb segfault
GNU gdb Fedora (6.8-37.el5)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
(gdb) run  >>Run The Program Under gdb
Starting program: /root/cprogrm/segfault
Program received signal SIGSEGV, Segmentation fault.
0x0804836f in main () at one.c:4
4 *s = 'H';
(gdb) backtrace
#0 0x0804836f in main () at one.c:4
These Type Error Will occur in C Programming, Vasp Programming when user give Large Matrix in Poscar file Input,Debugging Segmentation Fault

No comments:
Write comments