I have a program which takes the input from file which have 2^20 lines.
It throws error after 1000082(for fgets) 1000000(for getline(fp,str)) line it throws segmentation fault.
gdb report is as follows:
(gdb) bt
#0 0x00000032fd06106d in fgets () from /lib64/libc.so.6
#1 0x0000000000402f58 in main (argc=50, argv=0x32fd01d8b4) at corex.cpp:28
(gdb)
Though when i simply print the string in while loop, it runs fine upto EOF.
what could be the problem?
Here is the code snippet.
If you have a memory overrun in some other piece of code, it will have some impact on longer running programs. It's impossible to tell without seeing the code.
I'd recomend whitling down your app to the smallest code that reproduces the problem. If you still don't get it, post the code so someone can take a look.