File handle problem Setting a debug breakpoint causes a hang

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.

So, no one has any ideas? :) This could be tricky. If I figure it out I will be sure to post the answer so anyone else that runs into this can get around it.

I was able to get around the issue by instead debugging with a smaller input file.

I have a new problem in EmuDebug where if I set a debug breakpoint within the kernel function I get an error that states “The breakpoint will not currently be hit. Invalid file line.” If I try to set a breakpoint in the template_kernel kernel function it works fine, but my function has some problem.

I tried moving my kernel to the same file as template_kernel and again I was unable to break in my function, but the breakpoint in the template_kernel function worked fine. Anyone else ever see anything like this?

Thanks.

If anyone gets the error: “The breakpoint will not currently be hit. Invalid file line.”

Try changing the .cu file that contains the kernel function to not be built (if already including it from the main .cu file). This seemed to fix the issue for me.