Saturday, March 26, 2011


Error_File_Corrupt When Moving A File | Chkdsk at Reboot

Many tools use temp files to create a new file and then use MoveFileEx to move the temp file over the existing file. In some cases Subversion does this multiple times in just a second. In this case Windows 7 starts returning ERROR_FILE_CORRUPT where older Windows versions returned ACCESS DENIED like errors.

This is not a big deal by itself, but this error is also broadcasted to other parts of the system.

  • * You get a status bar popup indicating that you should run chkdsk.exe to check your disk
    * A chkdsk run is scheduled for the next reboot.

Several Subversion users have declared their hard disk broken because of this bug misreporting one error after another

I can replicate this behavior with a simple C++ program on Windows 7 (multiple versions on different PC's), but I can't replicate this issue on Windows Vista or older systems.
(These start returning access denied constantly).

On Windows vista you only get the access denied (error 5) and the application doesn't quit. If you explicitly mark the directory as not to be indexed by Windows search and disable your virus scanner you get +- the Vista behavior. Either one of these can get you the errors.

Microsoft Claims that no actual corruption has occurred.

This is a known regression in Windows 7 in the NTFS file system.  It occurs when doing a superceding rename over a file that has an atomic oplock on it (atomic oplocks are a new feature in Windows 7).

The indexer uses atomic oplocks which is why it helped when you disabled the indexer.  Explorer also uses atomic oplocks which is why you are still seeing the issue.  When this occurs STATUS_FILE_CORRUPT is incorrectly returned and the volume is marked "dirty" which is a signal to the system that chkdsk needs to be run.  No actual corruption has occurred.


About bench3 -

Haja Peer Mohamed H, Software Engineer by profession, Author, Founder and CEO of "bench3" you can connect with me on Twitter , Facebook and also onGoogle+

Subscribe to this Blog via Email :