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.

Recommended Answers

All 3 Replies

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.

commented: Nice +19

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.

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.

commented: Yes. +26
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.