LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 11-29-2004, 08:02 AM   #1
ntduongntd
LQ Newbie
 
Registered: Nov 2004
Posts: 2

Rep: Reputation: 0
segmentation fault


Hi everybody,

My C program writes output to a file but after the file size reaches to 8.1M ,i gets the "Segmentation fault" and the program is terminated.

I got no idea about what is going on.

Very appreciate if anyone could help.

Regards,

Andy
 
Old 11-29-2004, 08:04 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966
run your program within a gdb session

gdb ./myprogram
run
[wait for crash]
bt
 
Old 11-29-2004, 09:13 AM   #3
vharishankar
Senior Member
 
Registered: Dec 2003
Posts: 3,142
Blog Entries: 4

Rep: Reputation: 121Reputation: 121
Segmentation faults usually occur when a program tries to access a pointer that is not referenced or initialized. Anaylze your code carefully first to see if you have any pointers that are used without initializing.
 
Old 11-29-2004, 09:19 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966
well there are a LOT of things that can cause a segfault. here i'd doubt it would be a pointer as it's happening when a file is being written to previously succesfullly... more like a space issue, or a recursion problem even.
 
Old 11-29-2004, 12:00 PM   #5
MartinN
Member
 
Registered: Nov 2003
Location: Ronneby, Sweden
Posts: 555

Rep: Reputation: 30
Code, man! Show us some code!

gdb (the Gnu DeBugger) is an excellent tool, as mentioned by acid_kewpie. An alternative could be Valgrind:
http://valgrind.kde.org/
Valgrind is really good. It runs your application in a sandbox environment and tells you exactly where and when you write to unallocated memory or forget to delete memory. It currently only runs on x86-processors, though.

Happy hunting!
Martin
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what does Segmentation Fault mean ? baronlynx Linux - Newbie 10 10-25-2009 04:32 PM
yast segmentation fault, system freezing - nvidia driver at fault? BaltikaTroika Suse/Novell 2 12-02-2005 09:34 AM
Help !!! Segmentation fault mola Linux - Software 3 06-23-2005 11:13 AM
Segmentation fault tejas15_10 Programming 9 06-20-2005 09:12 AM
Segmentation fault santhosh_o Programming 3 10-26-2004 05:45 AM


All times are GMT -5. The time now is 03:00 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration