[clang-format] patch for bug 26125

Wei Mao via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 9 07:17:52 PST 2017


https://llvm.org/bugs/show_bug.cgi?id=26125. The proposed patch is in the
bug attachment

Bug 26125 - Clang format creates unwanted temporary files when batching
processing on windows

# Summary
A file mapping object prevents the temp file from being deleted. This is a
100% repro on Windows.

# Details
When formatting a file in place, the original file is mapped into memory
for reading.

Later when trying to overwrite the changed file, kernel!ReplaceFile()
renames the original file to <filename>~RFxxxx.TMP, creates a new file with
<filename>, copies formatted content to it, and finally deletes
<filename>~RFxxxx.TMP. Because there is still a open file mapping section
to the original file (now with new file name <filename>~RFxxxx.TMP), delete
fails with 0xc0000121 - STATUS_CANNOT_DELETE, leaving the temp file
untouched after the clang-format operation.

# Fix
Releasing the file mapping object early allows deletefile to proceed
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170209/8be77eb1/attachment.html>


More information about the cfe-commits mailing list