[LLVMbugs] [Bug 17960] New: Windows Rewriter/MemoryBuffer errors with 16KB large files
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Nov 16 10:36:45 PST 2013
http://llvm.org/bugs/show_bug.cgi?id=17960
Bug ID: 17960
Summary: Windows Rewriter/MemoryBuffer errors with 16KB large
files
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: alp at nuanti.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Various parts of tooling, the modernizers and migrators are mis-using the
Rewriter interface and causing Windows errors or crashes when rewriting large
files.
A typical error:
"Error while writing file: Error opening output file \'1.cpp\': The requested
operation cannot be performed on a file with a user-mapped section open"
The problematic pattern appearing frequently in clang's codebase is:
llvm::raw_fd_ostream FileStream(FileName.c_str(), ErrorInfo,
llvm::sys::fs::F_Binary);
Rewrite.getEditBuffer(ID).write(FileStream);
The fix is often simple as just replacing with:
Rewrite.overwriteChangedFiles()
overwriteChangedFiles() knows how to write to a temporary file and move into
place without writing over the mmaped source MemoryBuffer.
My analysis of the underlying problem:
The previous implementation was attempting to stream back directly to the
original file and failing if it was already memory mapped by MemoryBuffer,
an operation unsupported by Windows.
MemoryBuffer generally mmaps files larger than the physical page.
I've so far fixed two instances of the problem:
* r193594: RefactoringTool
* r194250: clang-format (PR17216)
There are a others yet to be fixed, some more involved, which I'm filing this
bug to track.
The clang lit tests have mostly missed this so far because there's a tendency
to keep test inputs checked into version control small, but in practice this
gets hit often when running the rewrite-based tools on Windows with real code.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131116/c025ef21/attachment.html>
More information about the llvm-bugs
mailing list