I'm trying to debug what looks like deadlock issue, happening on one remote machine. I did not manage to create a reproducible case for on my local machine, and neither does it happen 100% of the time on the remote one.
My main question is : can a file handle linger and still be visible after it is closed by a process?
The code is rather complex, but it looks basically like this:
CFile* file = new CFile;
// ...do stuff with the file
delete file
As far as I can tell from https://learn.microsoft.com/en-us/cpp/mfc/closing-files?view=msvc-160, delete
should ensure that the file object closes its handle (in effect calling CloseHandle
).
I verified (because of observing additional side-effects) that the program must have gone through the delete
call, and at the same time the file is still open 30 minutes later when looking at SysInternals handle.exe
.