I have a bizarre situation where my program will hang if I set a breakpoint and attempt to ‘Start Debugging’ in either Debug or EmuDebug after a function that reads the contents of a text file.
In my main function I have:
int main()
{
ReadFile(...params...);
<- Debug breakpoint here
}
The problem is my code gets stuck. I can see that the very last line in ReadFile is executed (it is a cout statement). If I hit pause when debugging I can see that the code is stuck is ‘osfinfo.c’ at this function:
/***
*void _unlock_fhandle(int fh) - unlock file handle
*
*Purpose:
* �  �  �  Release the lock associated with passed file handle.
*
*Entry:
* �  �  �  int fh  - CRT file handle
*
*Exit:
*
*Exceptions:
*
*******************************************************************************/
void __cdecl _unlock_fhandle (
�  �  �   int fh
�  �  �   )
{
�  �  �   LeaveCriticalSection( &(_pioinfo(fh)->lock) );
}
My ReadFile function looks something like this:
ReadFile()
{
ifstream infile;
infile.open("input.txt");
while(!infile.eof())
{
...do reading here...
}
infile.close();
cout << "File read complete." << endl;
}
If I execute my code with ‘Start Without Debugging’ I do not hit the issue, but I need to figure this out so I can debug of course. :-)
I should add the size of the text file is 54 MB… rather large.
Has anyone seen anything similar to this?
Thanks.