I’m getting segfaults when I run my project. Every time I run the program in gdb, the segfaults disappear. This behavior is not random: each time I run it in my shell it segfaults, each time I run it in gdb, the segfaults disappear. (I did recompile using -g).
So before I start adding printfs frantically everywhere in my code, I would like to know a few things:
- Is this behavior common?
- What’s the best way to approach the issue?
I don’t know if tests can be scripted since my application is interactive and crashes on a particular user input.
I didn’t paste my code here because it’d be way too long. But if anyone is interested in helping out, here it is:
https://github.com/rahmu/Agros
The easiest way to figure it out is to capture core dumps:
Then run your program. It will generate a
corefileThen use gdb:
And gdb will load and you can run a backtrace to see exactly what operation elicited the segfault.