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 08-22-2007, 12:01 AM   #1
go939
LQ Newbie
 
Registered: Jun 2007
Posts: 15

Rep: Reputation: 0
Program received signal SIGSEGV, Segmentation fault


hey there!

I'm trying to debug my program. i use the gdb as my debugging application. first i link all my source codes using make (makefile), then i use gdb test to debug the program. after which, i use the run command [ (gdb) run] to check for any possible error on my program. below are the result messages:

Starting program:
[Thread debugging using libthread_db enabled]
[New Thread - 1211099440 (LWP 5322)]

Program received signal SIGSEV, segmentation fault
[switching to thread - 1211099440 (LWP 5322)
0xb7f73442 in pthread_cond_destroy@@GLIBC_2.3.2

Can somebody explain to me what does this mean?
I'm just a newbie user of gdb.

Thanks a lot!
 
Old 08-22-2007, 12:36 AM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
Wow.

Where to begin?

First, I imagine that you typed the output by hand, because that should not be SIGSEV, but SIGSEGV. SIG stands for signal. For more information, google this:
Code:
Unix signal tutorial
SEGV stands for segment violation. Your program died because it tried to use a memory pointer that didn't point to a valid segment of memory. This can happen for several reasons. Here are some of the more, um, popular ones:
  1. The value in the pointer itself is NULL (usually all zero bits), which is a special value reserved to indicate that the pointer doesn't point anywhere.
  2. The value was derived by calculating some subscript in an array of data, and the subscript is either negative or too high, outside the bounds of the array (usually way too far outside).
  3. Some time ago the pointer may have had a valid value, but some part of the program stomped on the pointer; that is, it moved quite valid data to an invalid place in memory, and that invalid place in memory happens to be the pointer in question.
You'll need to learn much about gdb. To do so, go here.

Further, it's evident from the output that you're debugging a program using POSIX threads. If you are discovering at this point what SIGSEGV means, and you're already debugging a POSIX threads program, you're in an unenviable position.

May I ask whether you wrote this program yourself or whether it's an older program you're being asked to debug as part of your job, or what?
 
Old 08-22-2007, 12:45 AM   #3
go939
LQ Newbie
 
Registered: Jun 2007
Posts: 15

Original Poster
Rep: Reputation: 0
yap...type-error...

about the source code, I ported a source from win32 to C++ in Linux platform. There is already a source code from win32, so my work is to port the program in linux.

Thanks for your help.
 
Old 08-22-2007, 11:06 AM   #4
Quigi
Member
 
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
When gdb says "Program received SIGSEGV", you could type "where" -- it should spit out a list of which function called which. That may tell you which part of your program called pthread_cond_destroy -- directly or indirectly. But for case 3 (some other part of the program stomped the pointer) that won't help that much.

You could also give valgrind a quick try. It's usually used to find memory leaks (not your problem here), but it's quite good at reporting other suspicious things going on with your memory. It's not certain to find the problem, but not much effort to try.
 
Old 08-22-2007, 06:54 PM   #5
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537

Rep: Reputation: 87
Yeah I second the recommendation to try valgrind. It helped me figure out a strange segfault in my own application.
 
  


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
Program received signal SIGSEGV, Segmentation fault dayalan_cse Linux - Newbie 8 12-15-2006 12:05 AM
exit signal Segmentation fault Swakoo Linux - Newbie 3 12-22-2005 09:52 PM
Program received signal SIGPIPE, Broken pipe. grupoapunte Programming 1 06-03-2005 05:49 AM
Program received signal SIGSEGV, Segmentation fault ims_mca Linux - Distributions 0 03-09-2005 04:16 AM
SIGSEGV- segmentation fault during execution ashwinipahuja Programming 5 05-02-2004 10:02 PM

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

All times are GMT -5. The time now is 07:10 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