943,931 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 656
  • C++ RSS
Oct 31st, 2009
0

Pinpoint a Segmentation Fault

Expand Post »
I wrote a program to solve a system of linear equations. It works fine with the VS compiler. But when I try to run it using Cygwin, I get a seg fault(core dumped). But it does not say where the seg fault is.
I am using the following commands:
to complie: g++ -Wall -o main.out main.cpp
to run: ./main.out

Is there an option that i can put while running so that I can know on which line the seg fault is.
Reputation Points: 10
Solved Threads: 1
Light Poster
axed is offline Offline
28 posts
since Oct 2009
Oct 31st, 2009
0
Re: Pinpoint a Segmentation Fault
show the code.
Reputation Points: 10
Solved Threads: 10
Light Poster
niXman is offline Offline
39 posts
since Oct 2009
Nov 1st, 2009
0
Re: Pinpoint a Segmentation Fault
Try g++ -Wall file.c , I guess some of the apis you are using does not work with g++ .
Reputation Points: 769
Solved Threads: 128
Banned
ithelp is offline Offline
1,910 posts
since May 2006
Nov 1st, 2009
0
Re: Pinpoint a Segmentation Fault
The bovious thing to do is to run it in the debugger e.g. gdb or ddd
Compile with g++ -g -o Prog prog.cpp, and the run as ddd Prog . When it hits the seg-fault, use up until you see the problem (backtrace in gdb). It is likely that the fault is say in a sta

There is also another method that is much more rigerous, that is to use valgrind http://valgrind.org/. [Don't think this works on linux] But run your program with valgrind Prog and you get a long list of the memory you accessed without initializing and memory that you didn't free.
Reputation Points: 749
Solved Threads: 134
Practically a Master Poster
StuXYZ is offline Offline
660 posts
since Nov 2008
Nov 1st, 2009
0
Re: Pinpoint a Segmentation Fault
Thanks a lot.
Reputation Points: 10
Solved Threads: 1
Light Poster
axed is offline Offline
28 posts
since Oct 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Dynamic Adding of Widgets in GTKMM
Next Thread in C++ Forum Timeline: telnet server disconnects sockets too quickly





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC