I have a program which produces a fatal error with a testcase, and I can locate the problem by reading the log and the stack trace of the fatal. It turns out that there is a read operation upon a null pointer.
But when I try to attach GDB to it and set a breakpoint around the suspicious code, the null pointer just cannot be observed! The program works smoothly without any error.
This is a single-process, single-thread program, and I didn’t experience this kind of thing before. Why is it?
Appended: I also tried to call the pause() system call before the fatal-trigger code, and expected to make the program sleep before the fatal point and then attach GDB on it on-the-fly, sadly, no fatal error occurred.
It’s only guesswork without looking at the code, but debuggers sometimes do this:
I don’t have a quote on GDB, but I do have one on valgrind (granted the two do wildly different things..)
My program crashes normally, but doesn’t under Valgrind, or vice versa. What’s happening?
Same would go for GDB.
So the true problem is likely in your program.