[llvm-bugs] [Bug 35485] New: clang is not resilient to source files changing length underneath it
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Nov 30 13:59:50 PST 2017
https://bugs.llvm.org/show_bug.cgi?id=35485
Bug ID: 35485
Summary: clang is not resilient to source files changing length
underneath it
Product: clang
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: caustin at gmail.com
CC: llvm-bugs at lists.llvm.org
At Facebook, engineers have reported that clang will sometimes segfault if the
developer saves a file in the middle of compilation.
While tracking down an unrelated bug, I noticed that this appears to be because
SourceManager has UserFilesAreVolatile set to false which eventually causes
MemoryBuffer::getOpenFile to be called with isVolatile false, which memory maps
it. When memory mapping a file whose length has changed underneath it,
accessing pages beyond the end of the backing file results in a SIGBUS. In
addition, I believe line number computation expects a trailing nul byte, which
is implemented by mapping one byte larger than the file (assuming the file is
not exactly on a page boundary). But if the file has since expanded, that byte
is no longer null, and clang SIGSEGVs while computing line numbers.
It seems like UserFilesAreVolatile should be set true for non-system files.
#35333 looks related. And possibly #20880.
--
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/20171130/bb43ec48/attachment.html>
More information about the llvm-bugs
mailing list