I know segmentation fault means that the process has attempted to access certain memory that it’s not allowed to.
I’m running some program written by others using C++. And when my input is large (around 1GB), there’ll be a segmentation fault even though I requested 30GB memory; while when input size is quite small, it goes well.
So what shall I do? Is it because there’s not enough memory? I’m really kind of a newbie without much knowledge of C++. I don’t even know which part of the code controls memory allocation.
Thanks to BLender, line from the debugging is:
Program received signal SIGSEGV, Segmentation fault.
0x0000003fbd653174 in _IO_vfscanf_internal ()
from /share/bin/intel/cc/10.1.015/lib/tls/x86_64/libc.so.6
Your code calls
mallocseveral times, but neverfree, so it uses quite a lot of memory. And it never checks for an out-of-memory condition…My suggestion is that you change all the calls to malloc to something like:
And see what happens.