Quoting Aris Santillan <[EMAIL PROTECTED]>:
> What is
> Segmentation Fault (core dump)
Linux, like other Unix-like operating systems, is a protected mode OS.
Each of the several processes that are running in the system is protected
from being intentionally or accidentally written over by another process.
If process A attempts to write to memory assigned to process B, the the
OS aborts process A, announces a "Segmentation Fault",and (on request)
writes into a file called "core" the memory image of process A.
Accidental overwriting usually results from improperly written programs.
A typical case is the following:
extern int stat(const char *filename, struct stat *buf);
int result;
struct stat *pbuff;
result = stat("/etc/passwd", pbuff);
Now function stat() expects the second argument to be a pointer to an
existing "struct stat" which it will fill in with actual stat data about
/etc/passwd. But the programmer supplied a pointer pbuff (which is
probably pointing to some random location in ram, possibly in another
process). When the stat() function call is made, you get a "Segmentation
Fault"
The correct way of writing this piece of code is:
extern int stat(const char *filename, struct stat *buf);
int result;
struct stat buff;
result = stat("/etc/passwd", &buff);
Now &buff is a pointer to the existing struct stat buff.
> how can i solve this?
Ask the programmer to rewrite his program. If you are the programmer's
boss, and the programmer consistently makes this error, you should
fire him and hire a better one.
P~Manalastas
## Pablo Manalastas, Dept. of Information Systems & Computer Science
## Ateneo de Manila University, P.O. Box 154, Manila, SMS +639178992884
## Email: [EMAIL PROTECTED], Web http://curry.ateneo.net/
## Linux user #5037, http://counter.li.org
## Erdos Number Project #2, http://www.oakland.edu/~grossman/Erdos2
_
Philippine Linux Users Group. Web site and archives at http://plug.linux.org.ph
To leave: send "unsubscribe" in the body to [EMAIL PROTECTED]
Fully Searchable Archives With Friendly Web Interface at http://marc.free.net.ph
To subscribe to the Linux Newbies' List: send "subscribe" in the body to [EMAIL
PROTECTED]