0

I am sick of segmentation faults. This is the last straw. How to tame this ferocious wild beast? For small programs it can be debugged. But when dealing with large programs such as implementing a b-tree with thousands of pointers it is a nightmare to pinpoint the location of segmentation fault location.

4
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by thomas_naveen
1

That's why you should write and debug such programs in small sections. I suppose you are using *nix, so learn to use a debugger such as dbg, which will pinpoint the seg fault for you by using the core file. The program first has to be compiled for debug -- I think its the -g option.

Votes + Comments
Nice
0

I am sick of segmentation faults. This is the last straw. How to tame this ferocious wild beast? For small programs it can be debugged. But when dealing with large programs such as implementing a b-tree with thousands of pointers it is a nightmare to pinpoint the location of segmentation fault location.

Good programming habits, and as mentioned, building in incremental chunks, tend to be your best bets. If bad idioms carry forth into lots of code it is indeed a nightmare.

1

Welcome to the club!!

However, it is fairly easy to identify SEG faults once you can competently use a debugger. Compile with -g option to use binary with debugger.

There are some cases where even the debugger can't help you.

Thorough analysis of the code only can help you there.

Votes + Comments
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.