Debug error checking

I have a program which used to work fine until I added some new set of routines. The segmentation fault occurs at a place where I have not touced the code. It happens in places like reading a file (which it reads ok and error happens in somewhere in the middle of the data set. The input data is a time vaying input file). I checked the new code several times by printing the code and reviewing it thoroughly. But the error still happens.
So, I got into debugging and captured the error location.

I go the following error during debugging

Signalled SIGSEGV at 0x3E5D472DBA, function _IO_un_link_internal, file interp.c
0x3E5D472DBA: 48 8B 40 68 movq 104(%rax),%rax

pgdbg> where

#1 _IO_fclose@@GLIBC_2.2.5 address: 0x3E5D46611D
=> #0 _IO_un_link_internal file: interp.c address: 0x3E5D472DBA

Does this relate to closing a file?
This happens afer running the model for 3 months of simulation time. Ihave to run onr more month of simulation to complete a successful run.
Please let me know as how I can fix this problem.


Hi Venkat,

Unfortunately, I would know what’s wrong with your program. Most likely some memory is getting corrupted somewhere or the new code perturbed an existing error. Then again, the error is occurring when you close a file so it could be a problem with your file or file system.

Are you able to back out the new code? I’d start there and then add the routines back in one by one until the error occurs. You might also want to try using Valgrind ( to see if there are any memory issues.

  • Mat