I'm running a program in Linux. This program reads a file, execute some commands based on the content of the file. After completing all the commands, the program closes the file. The program crahses (Segmentation Fault) when it closes the file. I used gdb stack trace (bt) to track where the Segmentation fault occurred and found that it occurs inside the function fclose@@GLIBC_2.1 () from /lib/tls/libc.so.6.
Here is the section of code that closes the file:
Here is the logs:
Program received signal SIGSEGV, Segmentation fault.
0xb7386333 in fclose@@GLIBC_2.1 () from /lib/tls/libc.so.6
If you've any idea why the program crashes inside fclose@@GLIBC_2.1 () from /lib/tls/libc.so.6, please help.
Any suggestion would be appreciated.