<div dir="ltr">Good catch Kim, send a patch to cfe-commits.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 10, 2014 at 7:52 AM, Kim Gräsman <span dir="ltr"><<a href="mailto:kim.grasman@gmail.com" target="_blank">kim.grasman@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Ivan,<br>
<span class=""><br>
> The issue seems definetly linked to file size. I took dummy.h and ran it through the monitor. (bad trace)<br>
> Then I took dummy.h, removed 90% of the lines from the bottom, and also ran it through the monitor. (good trace)<br>
</span>> [...]<br>
<span class="">> Around some function called llvm MemoryBuffer getOpenFile things start to go different.<br>
> I have no experience yet with llvm code base to pinpoint this.<br>
<br>
</span>This is good info; MemoryBuffer::getOpenFile conditionally uses file<br>
mappings or normal file reads depending on file size (see<br>
MemoryBuffer.cpp/shouldUseMmap).<br>
<br>
Since the mapping uses a stricter sharing mode than the normal file<br>
read, it's more likely to fail. Still not sure who's writing/deleting<br>
the file while Clang attempts to map it, can you make that out from<br>
your PM logs?<br>
<br>
Also, I think I found a bug in MemoryBuffer:<br>
<br>
Index: lib/Support/MemoryBuffer.cpp<br>
===================================================================<br>
--- lib/Support/MemoryBuffer.cpp        (revision 219027)<br>
+++ lib/Support/MemoryBuffer.cpp        (working copy)<br>
@@ -185,7 +185,7 @@<br>
<br>
 public:<br>
   MemoryBufferMMapFile(bool RequiresNullTerminator, int FD, uint64_t Len,<br>
-                       uint64_t Offset, std::error_code EC)<br>
+                       uint64_t Offset, std::error_code &EC)<br>
       : MFR(FD, false, sys::fs::mapped_file_region::readonly,<br>
             getLegalMapSize(Len, Offset), getLegalMapOffset(Offset), EC) {<br>
     if (!EC) {<br>
<br>
If the error code were to be passed by value, the calling code seems<br>
meaningless:<br>
<br>
    std::error_code EC;<br>
    std::unique_ptr<MemoryBuffer> Result(<br>
        new (NamedBufferAlloc(Filename))<br>
        MemoryBufferMMapFile(RequiresNullTerminator, FD, MapSize, Offset, EC));<br>
    if (!EC)<br>
      return std::move(Result);<br>
<br>
That is, if mapping fails, we get an empty buffer back instead of<br>
falling through.<br>
<div class="HOEnZb"><div class="h5"><br>
- Kim<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br></div>