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: unassignedclangb...@nondot.org
Reporter: caus...@gmail.com
CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs