I have a pretty decent sized program (~1000 loc) .
When i run the program ,
./indexer
Gives segmentation fault on 800th iteration .
But when i do
gdb indexer
run
It goes well beyond 800th and shows seg fault at around 1200th iteration .
I dont understand why it is happening like this . Any pointers to possible mistake I am doing ?
EDIT:
The question is what might be reason for different behaviour of executable under the two conditions ?
The conditions under which your program runs can be very different when run with the debugger and without. If you have a bug in your program, especially a bug that is undefined behaviour, then anything could happen.
Since the problem still happens when using the debugger, I would debug that first, and then if the problem is solved when not running under the debugger, you’re done. Otherwise you’ll have a bit more work to do.