Alex Rivera | Logout

Determine the line of code that causes a segmentation fault?

Asked 2010-05-20T17:39:29.653
269

How does one determine where the mistake is in the code that causes a segmentation fault?

Can my compiler (gcc) show the location of the fault in the program?

Edit
Report

1 Answer

93

Also, you can give valgrind a try: if you install valgrind and run

valgrind --leak-check=full <program>

then it will run your program and display stack traces for any segfaults, as well as any invalid memory reads or writes and memory leaks. It's really quite useful.

answered 2010-05-20T19:24:18.967

Your Answer