LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-30-2004, 04:41 AM   #1
ashwinipahuja
Member
 
Registered: Mar 2004
Posts: 79

Rep: Reputation: 15
Question SIGSEGV- segmentation fault during execution


I am getting a SIGSEGV- segmentation fault
I have studied the code but cannot find out much.
wut are the most common problems for this error.
 
Old 04-30-2004, 05:34 AM   #2
eshwar_ind
Member
 
Registered: Feb 2004
Location: Bangalore
Distribution: Redhat
Posts: 144

Rep: Reputation: 15
As far as i have known The reason for this error is Invalid memory access. The most common way of commiting this mistake is while you are doing string operations, closing the file pointer more than once, and wrting on readonly memory.

Use debuggers or printf to find out the error.

check the return values of each and every library function.
Thats all i know about it.
Bye,
Eshwar.
 
Old 04-30-2004, 03:31 PM   #3
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
You can find the place (function) your program has a problem using
gdb progname
run
(the program will run, when it segfaults: )
bt
(shows an 'execution trace', function at the top was stared as the last one, there's a high probability there's a problem in it - or it uses data that's incorrect)
 
Old 05-02-2004, 08:10 AM   #4
jinksys
Member
 
Registered: Aug 2003
Location: 63123
Distribution: OpenSuSE/Ubuntu
Posts: 419

Rep: Reputation: 35
Segmentation faults occur when a process tries to access memory outside its bounds.
In processes that arent trying to do something malicious, this usually happens when
a pointer is returned from a function and is not tested whether it is valid. Look at
your code and make sure your error checking uses == and not =. If you still cant
find it, post your code.
 
Old 05-02-2004, 08:14 AM   #5
chris78
LQ Newbie
 
Registered: Mar 2004
Location: germany
Distribution: Slackware & RedHat
Posts: 28

Rep: Reputation: 15
Quote:
Originally posted by jinksys

your code and make sure your error checking uses == and not =.
Hehe thats a quite common one.

if (t_ptr=NULL) FREE(t_ptr);

Or missing & or * in front of function arguments or assignements.

Chris
 
Old 05-02-2004, 10:02 PM   #6
nodger
Member
 
Registered: Oct 2003
Location: Ireland
Distribution: Slackware 9.1, Ubuntu
Posts: 192

Rep: Reputation: 30
get a program called valgrind. It will tell you all the invalid reads/writes in your prog.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
yast segmentation fault, system freezing - nvidia driver at fault? BaltikaTroika SUSE / openSUSE 2 12-02-2005 09:34 AM
Xine SIGSEGV fault when playing anything JamieBrown Linux - Software 0 06-09-2005 02:11 PM
Sigsegv - segmentation faul binda Linux - Hardware 1 03-31-2005 09:19 AM
Program received signal SIGSEGV, Segmentation fault ims_mca Linux - Distributions 0 03-09-2005 04:16 AM
oz 3.3.5 opera 7.30 SIGSEGV fault? Brain Drop Linux - Laptop and Netbook 1 04-03-2004 06:45 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration