Cascade errors can happen on forcefully closing handles
In his recent Windows Confidential article Win32 and Shell Guru Raymond Chen talking about the caveats of forcefully closing the handles.
In many situations as a windows user you will definitely faced “File is being used by another process” error when you try to delete or access a file. As a solution for our impatience or to kill the dominance of other process you may forcefully close the file handles. Here are many utilities to close the files being used by foreign application. Tools like Process Explorer allows users to forcefully close any handles opened by any process in the system.
The issues are many
If the the handle is closed earlier by another application, when the original owner will get invalid handle error when it tries to close the corresponding handle.
The invalid handle error may come again if the application uses the handle again. Things may even worse, if the handle value is reused by operating system when the user tries to open another files. As far as the application concerned it got a valid handle value and it’s supposed to point the first file it has opened, in fact the first handle pointer actually points to second file. This may lead data corruption by writing the data intended for the first file is actually written to another file.
Now first and second file handles are actually pointing to the second file and as per the programming logic, if the first file handle is closed, it’s actually closing the second file and you’ve created the same situation which happened to the file earlier. The second file handle got invalid and this can lead to cascaded error.
In the above condition , the error happened when you opened a new file, but what’ if a it’s another kernel object like a mutex, by closing the handle, the mutex handle become invalid and by losing the synchronization, it may lead again for data corruption.
He also explain data corruption issues with search index when forcefully closing handles. Please see the original technet article to know issues with force-handle-close.
