Program received signal SIGSEGV, Segmentation fault
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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:
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:
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.
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).
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?
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.